Correctly pass watcher to another loop
Marc Lehmann
schmorp at schmorp.de
Mon Jun 25 11:40:08 CEST 2012
On Sun, Jun 24, 2012 at 07:39:18PM +0400, Vladimir Afinello <vovan.af at gmail.com> wrote:
> The problem seems to desappear since I started to wake the current thread
> loop after stopping a group of watchers and also splitted one read/write
I am still confused about this thread issue - when you stop a watcher, you
normally _are_ in the "current thread". The only time you need to wake up the
loop would be if you locked the loop with acquire/release callbacks, using an
ev_async watcher.
If you stop the watcher while ev_run executes in another thread, then
thats your problem, and waking up the loop will not solve your problem,
just hide the race condition for somewhat later, or trash libevs internal
data structures, which is likely whats happening (and the assertion
probably doesn't trigger when you start the watcher, but when you stop
it).
If that isn't your problem, the bug must be somewhere else in your code -
something almost certainly trashes libevs data structures, and that almost
certainly is lack of locking in your code somewhere.
In general, twiddling around with threads until the program doesn't crash
anymore is a sure way to get random crash bugs later.
--
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