=head1 NAME

UniEvent::Prepare - run the given callback once per loop iteration, right before polling for i/o.

=head1 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;



=head1 DESCRIPTION

The Prepare handle is useful for doing some actions before polling for I/O.
It is inherited from L<UniEvent::Handle>.



=head1 METHODS

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

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

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

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


=head2 new([$loop = default])

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


=head2 start([$callback])

Starts the prepare 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 prepare handle, i.e. makes it inactive for the next event loop iteration.


=head2 callback($sub)

=head2 event()

Callback signature:

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

See L<UniEvent/"EVENT CALLBACKS">


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

Method C<on_prepare> will be called.

See L<UniEvent/"EVENT LISTENER">


=head2 call_now()

Immediately ivokes assigned callbacks and listeners.


=cut
