Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Waking threads that do periodic checks

by BrowserUk (Pope)
on Sep 25, 2011 at 06:17 UTC ( #927711=note: print w/ replies, xml ) Need Help??

in reply to Waking threads that do periodic checks

This is easy to do, though I agree there may well be better ways of solving the real problem:

#! perl -slw use strict; use threads; use threads::shared; my $quit :shared = 0; $SIG{INT} = sub { print 'SIGINT'; $quit = 1; }; async { while( not $quit ) { my $wakeup = time() + 60 * 60; print( $quit ), sleep 1 while not $quit and time() < $wakeup; ## Do the hourly task; } }->detach; sleep 1 while not $quit; __END__ c:\test>junk60 0 0 SIGINT

The cpu cost of waking once per second is nominal.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Comment on Re: Waking threads that do periodic checks
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927711]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-02-01 12:08 GMT
Find Nodes?
    Voting Booth?

    My top resolution in 2015 is:

    Results (263 votes), past polls