NAME
UniEvent::Prepare - run the given callback once per loop iteration, right before polling for i/o.
SYNOPSIS
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;
DESCRIPTION
The Prepare handle is useful for doing some actions before polling for I/O. It is inherited from UniEvent::Handle.
METHODS
All methods of UniEvent::Handle also apply.
create($callback, [$loop = default])
my $handle = UniEvent::Prepare->create(sub { say "hi" });
Creates and starts a prepare handle. Alias for new($loop)
+ start($callback)
.
new([$loop = default])
Constructs new Prepare handle and binds it to the specified event loop
start([$callback])
Starts the prepare handle, i.e. makes it active for the next even loop iteration. Optionally it adds the $callback
to the event listeners.
stop()
Stops the prepare handle, i.e. makes it inactive for the next event loop iteration.
callback($sub)
event()
Callback signature:
my $handle = shift; # the "prepare" handle itself
See "EVENT CALLBACKS" in UniEvent
event_listener($delegate, [$weak])
Method on_prepare
will be called.
See "EVENT LISTENER" in UniEvent
call_now()
Immediately ivokes assigned callbacks and listeners.