Where's AnyEvent's run_one_timeslice?

Darin McBride darin.mcbride at shaw.ca
Fri Aug 7 16:03:20 CEST 2015

On Thursday August 6 2015 9:32:45 PM Mike Schilli wrote:
> While porting a module from POE to AnyEvent, I found myself in the
> unfortunate situation of having to deal with a synchronous (aka
> blocking) function that I have no control over and can't easily
> redesign.
> POE solves the problem by inverting control, by calling back into the
> event loop until a condition is met, like:
>     sub blocking_function {
>        while( !condition ) {
>            POE::Kernel->run_one_timeslice();
>        }
>     }
> Since I can't block in a callback in AnyEvent (via a condvar or even
> via Coro), is there a similar way I can call back into the event loop
> to run a slice and check back regularly if my condition is met, which
> is when I exit my blocking function?

Via Coro, I think you just use Coro::cede.  Not sure about plain AE, though.

> For the record, this is about porting Curses::UI to AnyEvent, there's
> a deja-vu here, and running the POE version in AnyEvent worked ok for
> a while, but I'd rather have a native port:
> http://lists.schmorp.de/pipermail/anyevent/2013q1/000421.html

More information about the anyevent mailing list