once#

Wait once for a handle to become ready, a timeout, or the first of the two, without keeping a watcher object.

Synopsis#

EV::once $fh, EV::READ, 10, sub { my ($revents) = @_; ... };
EV::once undef, 0, 2.5, sub { ... };    # a plain timeout

What you get back#

Nothing. When the handle is ready or the timeout passes, the callback is called once with the events received: a combination of EV::READ, EV::WRITE, EV::TIMER and EV::ERROR. Then both watchers are gone.

Edge cases#

  • undef as the handle (with 0 events) waits for the timeout only; an undef or negative timeout waits for the handle only.

  • The callback receives only the events, not a watcher.

Differences from upstream#

Fully compatible with upstream. Covered by t/81-xs-native/EV/120-upstream-02_once.t.

See also#

  • EV::io - a watcher for a handle, kept as long as needed

  • EV::timer - a watcher for a timeout