Using Thread::Queue.
Logic:
- Collect list of things to process (into a Thread::Queue)
- Execute threads using Thread::Queue for loop
- Each thread has what it needs to process a Queue item
Using this style structure:
@threads=map {
threads->create(sub {
(all things required for each thread to process a Thread::Queue item via a while(defined()) { } structure)
});
} 1 .. <numthreads>;
$_->join for @threads
Not using the threads:shared. (Looked at it a couple times, but not sure that I've encountered a use case for it -or- simply don't have sufficiently complex code to justify?)
Thanks!
In reply to Re^2: Perl and Threading
by scorpion7
in thread Perl and Threading
by scorpion7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |