UniEvent::Prepare - run the given callback once per loop iteration, right before polling for i/o.
my $h = UniEvent::Prepare->new($loop); $h->event->add(sub { say 'hello' }); $h->start; $loop->run_nowait; # prints 'hello' $loop->run_nowait; # prints 'hello' again $h->stop; $loop->run_nowait; # no effect $h = UE::prepare sub { ... }, $loop;
The Prepare handle is useful for doing some actions before polling for I/O. It is inherited from UniEvent::Handle.
All methods of UniEvent::Handle also apply.
my $handle = UniEvent::Prepare->create(sub { say "hi" });
Creates and starts a prepare handle. Alias for new($loop) + start($callback).
new($loop)
start($callback)
Constructs new Prepare handle and binds it to the specified event loop
Starts the prepare handle, i.e. makes it active for the next even loop iteration. Optionally it adds the $callback to the event listeners.
$callback
Stops the prepare handle, i.e. makes it inactive for the next event loop iteration.
Callback signature:
my $handle = shift; # the "prepare" handle itself
See "EVENT CALLBACKS" in UniEvent
Method on_prepare will be called.
on_prepare
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.