in reply to thread ids stringifying wrong in v5.12.4?
async does not return a "thread id", it returns a blessed thread handle. To get a thread id from a thread handle, use $threadHandle->tid;
Thus, there is no perpose in storing your thread handles in a hash -- where they will get stringified -- because you can (and do) obtain those handles from your joinable() sub.
Your while loop for joining the threads is horrible -- it obtains the same list over and over. It can be replaced by a simple:
printf "%d => %d\n", $_->tid, $_->join for @threads;
Provided you store your thread handles in the array @threads so:
push @threads, async { sleep 3*$i+5; $i };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: thread ids stringifying wrong in v5.12.4?
by samwyse (Scribe) on Dec 17, 2012 at 18:36 UTC | |
by BrowserUk (Patriarch) on Dec 17, 2012 at 19:11 UTC |