Mojo::IOLoop::Trigger(User Contributed Perl DocumentatMojo::IOLoop::Trigger(3)NAMEMojo::IOLoop::Trigger - IOLoop Trigger
SYNOPSIS
use Mojo::IOLoop::Trigger;
# Synchronize multiple events
my $t = Mojo::IOLoop::Trigger->new;
$t->on(done => sub { print "BOOM!\n" });
for my $i (1 .. 10) {
$t->begin;
Mojo::IOLoop->timer($i => sub {
print 10 - $i, "\n";
$t->end;
});
}
# Stop automatically when done
$t->start;
DESCRIPTIONMojo::IOLoop::Trigger is a remote control for Mojo::IOLoop. Note that
this module is EXPERIMENTAL and might change without warning!
EVENTSMojo::IOLoop::Trigger can emit the following events.
"done"
Emitted once the active event counter reaches zero.
ATTRIBUTESMojo::IOLoop::Trigger implements the following attributes.
"ioloop"
my $ioloop = $t->ioloop;
$t = $t->ioloop(Mojo::IOLoop->new);
Loop object to control, defaults to a Mojo::IOLoop object.
METHODSMojo::IOLoop::Trigger inherits all methods from
Mojo::IOLoop::EventEmitter and implements the following new ones.
"begin"
my $cb = $t->begin;
Increment active event counter, the returned callback can be used
instead of "end".
my $t = Mojo::IOLoop->trigger;
Mojo::IOLoop->resolver->lookup('mojolicio.us' => $t->begin);
my $address = $t->start;
"end"
$t->end;
$t->end(@args);
Decrement active event counter.
"start"
my @args = $t->start;
Start "ioloop" and register "done" event that stops it again once the
active event counter reaches zero.
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.1 2011-09-13 Mojo::IOLoop::Trigger(3)