in reply to Re: Perl and Threading
in thread Perl and Threading
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl and Threading
by choroba (Cardinal) on Nov 03, 2023 at 09:53 UTC | |
by scorpion7 (Novice) on Nov 06, 2023 at 17:13 UTC | |
by choroba (Cardinal) on Nov 06, 2023 at 17:31 UTC | |
by scorpion7 (Novice) on Nov 09, 2023 at 05:07 UTC |