=head1 NAME

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

=head1 SYNOPSIS

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



=head1 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 L<UniEvent::Handle>.



=head1 METHODS

All methods of L<UniEvent::Handle> also apply.


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

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

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


=head2 new([$loop = default])

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


=head2 start([$callback])

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


=head2 stop()

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


=head2 callback($sub)

=head2 event()

Callback signature:

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

See L<UniEvent/"EVENT CALLBACKS">


=head2 event_listener($delegate, [$weak])

Method C<on_idle> will be called.

See L<UniEvent/"EVENT LISTENER">


=head2 call_now()

Immediately ivokes assigned callbacks and listeners.

=cut