Adding watchers on the fly to event loops

Marc Lehmann schmorp at schmorp.de
Thu Jul 11 05:33:38 CEST 2013


On Wed, Jul 10, 2013 at 05:05:45PM +0530, Aravindh Ramaswamy <aravindhramu at gmail.com> wrote:
> Correct but that would require synchronization mechanisms between two
> threads( as is the case for me) like mutexes and condition variables.

Yes, but that's true for any communication between threads, or anything
that potentially runs in parallel.

> I considered the use of the queue but since watchers can pass custom data
> as well
> by type casting, I thought of passing the data using ev_async watcher in
> ev_async_send

first, ev_async_send is a synchronisation mechanism, and second, it has
no meaningful way to queue data that wouldn't require you to use another
synchronisatzion mechanism (like mutexes, atomic accesses &c).

> and then the recipient event loop while invoking the async_cb can make use
> of that information.
> Wont that work ?

Sure, but you can't escape the fundamental need for some synchronisation
mechanism.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list