Adding watchers on the fly to event loops
aravindhramu at gmail.com
Wed Jul 10 13:14:25 CEST 2013
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
> > 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
> 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
> 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
> The choice of a Deliantra, the free code+content
> -----==- _GNU_ http://www.deliantra.net
> ----==-- _ generation
> ---==---(_)__ __ ____ __ Marc Lehmann
> --==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
> -=====/_/_//_/\_,_/ /_/\_\
Thanks and Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the libev