NAME
UniEvent::Check - runs the given callback once after polling for I/O
SYNOPSIS
my $loop = UniEvent::Loop->default_loop;
my $h = UniEvent::Check->new;
$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->reset;
DESCRIPTION
The Check handle is useful for doing post-I/O actions for a loop with the help of callback or listener. It is inherited from UniEvent::Handle.
METHODS
new([$loop = UniEvent::Loop->default_loop])
Constructs new Check handle and binds it to the specified event loop
start([$callback = undef])
Starts the check handle, i.e. makes it active for the next even loop iteration. Optionally it adds the $callback
to the event listeners.
stop()
Stops the check handle, i.e. makes it inactive for the next event loop iteration.
callback($code)
Sets the callback, which will be invoked after loop run. All previously set event listeners or callbacks will be discarded.
event()
Returns XS::Framework::CallbackDispatcher instance, where callback(s) can be assigned with. The callbacks will be invoked after loop run. The C++ interface is:
void(const CheckSP&);
i.e. the callback returns nothing and as an argument takes Check handle itself.
Multiple callbacks can be added via the XS::Framework::CallbackDispatcher interface.
event_listener($delegate [, $weak = false])
Delegates callback invocation to the $delegate
object of arbitrary class having on_check
method. The object can optionally be weakened.
The method will be invoked as
$obj->on_check($handle);
call_now()
Immediately ivokes assigned callbacks and listeners in the caller context (i.e. not waiting loop run).
CONSTANTS
TYPE
Check type constant