Where's AnyEvent's run_one_timeslice?

Mike Schilli mike.schilli at gmail.com
Fri Aug 7 06:32:45 CEST 2015


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?

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

-- 
-- Mike
Mike Schilli
office at perlmeister.com



More information about the anyevent mailing list