POE::Component::Schedule - Schedule POE events using DateTime::Set iterators
use POE qw(Component::Schedule); use DateTime::Set; POE::Session->create( inline_states => { _start => sub { $_[HEAP]{sched} = POE::Component::Schedule->add( $_[SESSION], Tick => DateTime::Set->from_recurrence( after => DateTime->now, before => DateTime->now->add(seconds => 3), recurrence => sub { return $_[0]->truncate( to => 'second' )->add( seconds => 1 ) }, ), ); }, Tick => sub { print 'tick ', scalar localtime, "\n"; }, remove_sched => sub { # Three ways to remove a schedule # The first one is only for API compatibility with POE::Component::Cron $_[HEAP]{sched}->delete; $_[HEAP]{sched} = undef; delete $_[HEAP]{sched}; }, _stop => sub { print "_stop\n"; }, }, ); POE::Kernel->run();
This component encapsulates a session that sends events to client sessions on a schedule as defined by a DateTime::Set iterator.
No need to call this in normal use, add() and new() all crank one of these up if it is needed. Start up a PoCo::Schedule. Returns a handle that can then be added to.
my $sched = POE::Component::Schedule->add( $session_object, $event_name, $DateTime_Set_iterator, @event_args );
Add a set of events to the schedule. The $session_object and $event_name are passed to POE without even checking to see if they are valid and so have the same warnings as ->post() itself. $session_object must be a real POE::Session, not a session ID. Else session reference count will not be increased and the session may end before receiving all events.
$session_object
$event_name
Returns a schedule handle. The event is removed from when the handle is not referenced anymore.
new is an alias for add
Removes a schedule using the handle returned from ->add or ->new.
DEPRECATED: Schedules are now automatically deleted when they are not referenced anymore. So just setting the container variable to undef will delete the schedule.
undef
POE, DateTime::Set, POE::Component::Cron.
You can look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-Schedule
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/POE-Component-Schedule
CPAN Ratings
http://cpanratings.perl.org/p/POE-Component-Schedule
Search CPAN
http://search.cpan.org/dist/POE-Component-Schedule/
This module is a friendly fork of POE::Component::Cron to extract the generic parts and isolate the Cron specific code in order to reduce dependencies on other CPAN modules.
The orignal author of POE::Component::Cron is Chris Fedde.
See https://rt.cpan.org/Ticket/Display.html?id=44442
dolmen@cpan.org
cfedde@cpan.org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
To install POE::Component::Schedule, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::Schedule
CPAN shell
perl -MCPAN -e shell install POE::Component::Schedule
For more information on module installation, please visit the detailed CPAN module installation guide.