Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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.

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 contemplating the Monastery: (6)
As of 2016-10-28 00:00 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (372 votes). Check out past polls.