NAME

POE::Component::Cron - Schedule POE Events using a cron spec

SYNOPSIS

use POE::Component::Cron;
use DateTime::Event::Crontab;
use DateTime::Event::Random;

$s1 = POE::Session->create(
	inline_states => {
		_start => sub {
			$_[KERNEL]->delay( _die_, 120 );
		}

		Tick => sub {
			print 'tick ', scalar localtime, "\n";
		},

		Tock => sub {
			print 'tock ', scalar localtime, "\n";
		}

		_die_ => sub {
			print "_die_";
		}
	}
);

# crontab DateTime set
$sched1 = POE::Component::Cron->add(
	$s1 => Tick => DateTime::Event::Cron->from_cron('* * * * *')->iterator(
		span => DateTime::Span->from_datetimes(
			start => DateTime->now,
			end	  => DateTime::Infinite::Future->new
		)
	),
);

# random stream of events
$sched2 = POE::Component::Cron->add(
	$s2 => Tock => DateTime::Event::Random->(
		seconds => 5,
		start	=> DateTime->now,
	)->iterator
);

# delete some schedule of events
$sched2->delete();

DESCRIPTION

This component encapsulates a session that sends events to client sessions on a schedule as defined by a DateTime::Set iterator. The implementation is straight forward if a little limited. As of this writing there is no machinism for deleting schedules once they have been added.

This is early Alpha code. The API is no where close to jelling. I'd love to hear your ideas if you want to share them.

METHODS

spawn

Start up a poco::cron. returns a handle that can then be added to.

add

Add a set of events to the schedule.

$cron->add( 
	$session,
	'event_name',
	DateTime::Set->iterator,
	@other_args_to_event\@session
);

SEE ALSO

POE, perl, DateTime::Set, DateTime::Event::Cron.

AUTHOR

Chris Fedde, <cfedde@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Chris Fedde

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.