in reply to Re^3: Threads From Hell #1: How To Share A Hash
in thread Threads From Hell #1: How To Share A Hash [SOLVED]
"...guarantee no duplicates..."
Sure can i - in this case ;-)
But the code works with dups, whether i use lock or not.
I tried this:
sub process { my $number = shift; # lock %result; $result{ threads->tid() } = shared_clone( { $number => factorial($number) } ); $semaphore->up; }
It works as expected:
./semaphore.pl 0.0276410579681396 { # tied threads::shared::tie 1 => { # tied threads::shared::tie 10 => 3628800, }, 2 => { # tied threads::shared::tie 10 => 3628800, }, 3 => { # tied threads::shared::tie 10 => 3628800, }, 4 => { # tied threads::shared::tie 11 => 39916800, }, }
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Threads From Hell #1: How To Share A Hash
by BrowserUk (Patriarch) on May 15, 2015 at 11:16 UTC | |
by karlgoethebier (Abbot) on May 15, 2015 at 11:54 UTC |