Coro::EV#

📦 max

Coro::EV - run Coro on the EV event loop.

use Coro;
use Coro::EV;

async { Coro::EV::timer_once 0.5; print "half a second later\n" };
EV::run;                      # or let Coro::AnyEvent drive it

Loading Coro::EV makes EV’s loop and Coro’s scheduler cooperate: before EV blocks for events it runs every ready coroutine, and when a coroutine becomes ready while EV sleeps, EV wakes up for it. That is what lets code in the linear Coro style wait on sockets and timers through EV - directly, or through Coro::AnyEvent, Coro::Handle and Coro::Socket, which use it when EV is the event loop.

Coro::EV::timer_once $seconds suspends the current coroutine for that long; Coro::EV::timed_io_once $fh, $events, $timeout waits for a filehandle to become readable or writable (EV::READ, EV::WRITE) and returns the events that occurred, or 0 on timeout.

This is a native implementation of the XS half of Coro 6.57’s Coro::EV, on the native EV module; its Coro/EV.pm is used unchanged.

Differences from upstream#

None.