UniEvent::Idle - runs the given callback once per loop iteration
my $h = UniEvent::Idle->new($loop); $h->event->add(sub { my $h = shift; # do some work if (done) { $h->stop;} }); $h->start;
Idle handle invokes callbacks once per loop iteration, before preparing them for I/O.
Adding the handle to the event loop causes it the loop to perform a zero timeout poll instead of blocking for I/O. Generally it is rather CPU consuming, so you should have a reason to do that.
The handle is inherited from UniEvent::Handle.
All methods of UniEvent::Handle also apply.
my $handle = UniEvent::Idle->create(sub { say "hi" });
Creates and starts an idle handle. Alias for new($loop) + start($callback).
new($loop)
start($callback)
Constructs new Idle handle and binds it to the specified event loop
Starts the Idle handle, i.e. makes it active for the next even loop iteration. Optionally it adds the $callback to the event listeners.
$callback
Stops the Idle handle, i.e. makes it inactive for the next event loop iteration.
Callback signature:
my $handle = shift; # the "idle" handle itself
See "EVENT CALLBACKS" in UniEvent
Method on_idle will be called.
on_idle
See "EVENT LISTENER" in UniEvent
Immediately ivokes assigned callbacks and listeners.
To install UniEvent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UniEvent
CPAN shell
perl -MCPAN -e shell install UniEvent
For more information on module installation, please visit the detailed CPAN module installation guide.