EV(3p)

NAME
Coro::EV - do events the coro-way, with EV

SYNOPSIS
 use Coro;
 use Coro::EV;

 EV::READ & Coro::EV::timed_io_once $fh, EV::READ, 60
    or die "timeout\n";

 EV::run;

DESCRIPTION
This module does two things: First, it offers some utility functions that might be useful for threads (although Coro::AnyEvent offers more and more portable functions), and secondly, it integrates Coro into the EV main loop:

Before the process blocks (in EV::run) to wait for events, this module will schedule and run all ready (= runnable) threads of the same or higher priority. After that, it will cede once to a threads of lower priority, then continue in the event loop.

That means that threads with the same or higher priority as the threads running the main loop will inhibit event processing, while threads of lower priority will get the CPU, but cannot completeley inhibit event processing. Note that for that to work you actually have to run the EV event loop in some thread.

RUNNING WITH OR WITHOUT A MAINLOOP
In general, you should always run EV::run, either in your main program, or in a separate coroutine. If you don't do that and all coroutines start waiting for some events, this module will run the event loop once, but this is very inefficient and will also not make it possible to run background threads.

To run the EV event loop in a separate thread, you can simply do this:

  async { EV::run };

FUNCTIONS

$revents = Coro::EV::timed_io_once $fileno_or_fh, $events[, $timeout]
    Blocks the coroutine until either the given event set has occurred on the fd, or the timeout has been reached (if timeout is missing or "undef" then there will be no timeout). Returns the received flags.

    Consider using "Coro::AnyEvent::readable" and "Coro::AnyEvent::writable" instead, they work with any AnyEvent-supported event loop.

Coro::EV::timer_once $after
    Blocks the coroutine for at least $after seconds.

    Consider using "Coro::AnyEvent::sleep" instead, which works with any AnyEvent-supported event loop.

AUTHOR/SUPPORT/CONTACT
   Marc A. Lehmann <schmorp@schmorp.de>
   http://software.schmorp.de/pkg/Coro.html