At 11:19 PM 7/16/02 +0000, Stas Bekman wrote:
>> From the command line, it works very well.
>>We are impleminting a very complex digital library system.
>>In same cases, we want to start parallel threads in order to minimize the
>>wait.
>>Let me try to explain with an example.
>>'A' start 4 threads, each of which prepares, and sends a request to another
>>server, and then collects its result. When all threads will be terminated,
>>'A' will merge the 4 results.
>>Is now more clear?
You should be able to use Thread::Pool for this.
$pool = Thread::Pool->new(
{
workers => 10, # or higher or lower, max simultaneous requests
do => sub {fetch from URL and return it},
} );
@jobid = ();
push( @jobid,$pool->job( $_ ) ) foreach @url;
foreach (@jobid) {
my $result = $pool->result; # do whatever you want with result X
}
>your problem is that you use the *old* threads (5005threads, pre-5.6.0),
>whereas mod_perl 2.0 is using ithreads (5.6.0+).
>>>my $t2 = new Thread(\&my_thread,'t2');
>do 'perldoc threads' with perl-5.8.0
Actually, to add to the confusion: only the Thread.pm and Thread::Signal.pm
modules are old 5.005threads modules. All the other Thread:: namespace
modules (except Malcolm Beattie's old version of Thread::Pool on CPAN) are
new "ithreads" modules. Only the true "pragma" modules threads.pm and
threads::shared.pm have remaind untouched. This was changed last week, as
described in Rafael's p5p
summary http://use.perl.org/article.pl?sid=02/07/15/0732235 ;-)
Liz