Adding watchers on the fly to event loops

Aravindh Ramaswamy aravindhramu at gmail.com
Wed Jul 10 13:14:25 CEST 2013


Thanks Marc.


On Wed, Jul 10, 2013 at 4:36 PM, Marc Lehmann <schmorp at schmorp.de> wrote:

> On Wed, Jul 10, 2013 at 03:57:40PM +0530, Aravindh Ramaswamy <
> aravindhramu at gmail.com> wrote:
> > I have started an empty event loop using ev_ref(loop) and ev_run(loop).
> > Now, I want to add watcher for EV_READ event to this loop on the fly as
> and
> > when
> > an event comes for EV_ASYNC.
> >
> > Is it possible to do so ?
>
> You can add watchers at any time when libev itself isn't executing. For
> example, from inside an ev_async callback (but why would you need ev_ref
> when
> you already have an ev_async watcher registered?).
>
>
Right. A mistake from my end. I didnt have EV_ASYNC in mind initially.
My doubt was should i use ev_suspend and ev_resume to do so.



> When using threads, you can provide your own mutex functions to lock
> libev's
> internal data, which makes it possible to add watchers even when the event
> loop itself is blocked. See the "thread locking example" in the docs for
> details.
>
> --
>                 The choice of a       Deliantra, the free code+content
> MORPG
>       -----==-     _GNU_              http://www.deliantra.net
>       ----==-- _       generation
>       ---==---(_)__  __ ____  __      Marc Lehmann
>       --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
>       -=====/_/_//_/\_,_/ /_/\_\
>



-- 
Thanks and Regards,
Aravindh.R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20130710/d48a0a43/attachment.html>


More information about the libev mailing list