NAME

UniEvent::Idle - runs the given callback once per loop iteration

SYNOPSIS

my $h = UniEvent::Idle->new($loop);
$h->event->add(sub {
    my $h = shift;
    # do some work
    if (done) { $h->stop;}
});
$h->start;

DESCRIPTION

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.

METHODS

All methods of UniEvent::Handle also apply.

create($callback, [$loop = default])

my $handle = UniEvent::Idle->create(sub { say "hi" });

Creates and starts an idle handle. Alias for new($loop) + start($callback).

new([$loop = default])

Constructs new Idle handle and binds it to the specified event loop

start([$callback])

Starts the Idle handle, i.e. makes it active for the next even loop iteration. Optionally it adds the $callback to the event listeners.

stop()

Stops the Idle handle, i.e. makes it inactive for the next event loop iteration.

callback($sub)

event()

Callback signature:

my $handle = shift; # the "idle" handle itself

See "EVENT CALLBACKS" in UniEvent

event_listener($delegate, [$weak])

Method on_idle will be called.

See "EVENT LISTENER" in UniEvent

call_now()

Immediately ivokes assigned callbacks and listeners.