in reply to Thread-safe modules and callbacks
And the issue that this won't work in a threaded-environment because the $count that gets updated is only accessible in one thread (since it is not declared as shared.) So, callbacks have to be thread-aware if they are going to be used in a threaded environment.our $count = 0; sub my_callback { warn "I've been called ".(++$count)." times\n"; ... } my $thread = threads->create(..., \&my_callback); $thread->join; print "count = $count\n"; # prints 0
Interesting problem...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Thread-safe modules and callbacks
by Saladino (Beadle) on May 09, 2008 at 23:22 UTC | |
by pc88mxer (Vicar) on May 09, 2008 at 23:30 UTC |