Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Re: a scheduler

by pope (Friar)
on Sep 18, 2002 at 12:11 UTC ( #198804=note: print w/replies, xml ) Need Help??


in reply to Re: Re: a scheduler
in thread a scheduler

Have you considered using POE ? If you have Time::HiRes installed, POE::Kernel will use it for timed events. And your code will be much shorter, with more elegant structure, and thus easier to maintain.

Here is a simple scheduler example:

use POE; $DELAY = 0.5; # every half a second sub do_something { my $kernel = $_[KERNEL]; print "Hello boy..\n"; $kernel->delay('wake_up!', $DELAY); } POE::Session->new( _start => sub { my $kernel = $_[KERNEL]; $kernel->delay('wake_up!', $DELAY); print "Session is started..\n"; }, _stop => sub { print "Session is stopped.\n"; }, 'wake_up!' => \&do_something, ); $poe_kernel->run;

Replies are listed 'Best First'.
Re: Re: Re: Re: a scheduler
by fredalbrecht (Novice) on Sep 18, 2002 at 15:59 UTC
    I have not yet come across POE. Will do some reading. I'm never sure what happens after/inside run (where do I run my normal code that is not related to the POE code ... newbie warning!) Will do some reading...<sigh>

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2020-01-20 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?