Correctly pass watcher to another loop
Marc Lehmann
schmorp at schmorp.de
Sun Jun 24 17:24:23 CEST 2012
On Sun, Jun 24, 2012 at 05:14:41PM +0400, Vladimir Afinello <vovan.af at gmail.com> wrote:
> > I am not sure what that means, but again, if the watchers are stopped,
> > then the loop will no longer access them.
>
> I mean, when I receive some data from one client in it's watcher receive
> callback - I need to pass this watcher and 5 other watchers from this
> thread/loop to another.
> And I perform stop() on all of them being in that receive callback
> function. So, does these 5+1 stop()'s affect the thread loop immediatelly?
Yes, as I said, the loop will not touch watchers once stopped, regardless
of when you stop them.
> If not - I have no idea why these watchers remain active when I start them
> in another thread.
Me neither, but the assert can only trigger on a started watcher.
On Sun, Jun 24, 2012 at 05:44:40PM +0400, Vladimir Afinello <vovan.af at gmail.com> wrote:
> I also haven't found the watcher.set(struct ev_loop*) implementation in the
It's in ev++.h, first set method in the file.
> Shouldn't it throw an exception on set() method if the watcher was pending
> at that moment?
Calling that method on an active watcher is always a bug, not an
exceptional condition. And in this case, the assert did catch the bug.
--
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