Creating a thread pool isn't hard.  Here's a rudimentary example that u
should be able to run with.

$x = 1;
share $working;
$jobs = new Thread::Queue;
${"t". ++$x} = thread->create("entrypoint") for (1..10);

sub entrypoint {
        for (;;) {
                $commanddata = $jobs->dequeue_nb;
                sleep 1 and next unless $commanddata;
                $working++;
                do_something($commanddata);
                $working--;
        }
}


Now u have a pool of threads, $t1 to $t10.  $working tells u how many are
available.  The message queue lets u send work that will be picked up by the
next available thread.

At 06:15 PM 12/9/2006 -0800, [EMAIL PROTECTED] wrote:
>How can I implement simple thread-pooling using perl 5.8 threads?
>I would need some way of injecting code into the loaded threads, have the
>ability to reuse threads, and keep track of thread slots available.
>
>A simple example would be great. I am not an expert when it comes to threads,
>just so you are aware.




--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to