ev_timer_start() appears to not wake up loop from epoll_wait()

Marc Lehmann schmorp at schmorp.de
Sat Apr 11 20:05:41 CEST 2015


On Fri, Apr 10, 2015 at 02:20:33PM -0700, Chris Zahka <czahka at gmail.com> wrote:
> It appears as though ev_timer_start() does not cause the backend_poll to
> wake up. Is this the expected behavior or am I doing something wrong?

I see no locking whatsoever in your example - when accessing shared data
structures from threads (such as a watcher or an event loop) you have (in
general) to use locking, otherwise you run into race conditions.

Note that thread programming is hard in general, so if you are not
comfortable with mutexes or other synchronisation primitives, you should
probably try to stay single threaded for the time being, or use a very
different model (such as one event loop per thread).

See the "THREAD LOCKING EXAMPLE" in the libev docs for an example of how
to use pthread mutexes to share a loop.

-- 
                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