Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Checking thread status
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Tassilo v. Parseval, post: 4795035"] Also sprach [email]programmacist@yahoo.com[/email]: Note what the documention of 'Thread' says on 'done': done The "done" method returns true if the thread you're checking has finished, and false otherwise. (Not avail- able with ithreads.) Since 'use threads' is using the ithreads-model, you're out of luck. You can still cover that case by installing a handler for the pseudosignal __DIE__ in your worker thread: use threads; use threads::shared; my $working : shared; sub work { local $SIG{__DIE__} = sub { print "Abnormal termination: ", shift; $working = 0; }; print "Worker has started\n"; sleep (3); die "died\n" if rand > 0; $working = 0; } $working = 1; my $worker = threads->create('work'); while ($working) { print "Main is performing a task\n"; sleep (1); } $worker->join(); print "Moving on...\n"; So now your worker thread will set $working to zero even under some abnormal condition that would have normally caused an imediate death. This warning is a little misleading. perldiag says: thread failed to start: %s (F) The entry point function of threads->create() failed for some reason. 'work' is your entry point function and having it die satisfies the condition for "failed for some reason", I reckon. Contrary to what perldiag thinks (the (F) indicates it's a fatal trappable error), this is merely a warning and it can be shut up by installing a handler for __WARN__. Tassilo [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Checking thread status
Top