ev_timer problem
vvvua
vvvua at faust.net.ua
Tue Jul 15 18:18:13 CEST 2008
Marc Lehmann wrote:
> On Mon, Jul 07, 2008 at 03:54:21PM +0300, vvvua <vvvua at faust.net.ua> wrote:
>
>> When ev_loop finishes to maintain all registered timers, it waits on
>> epoll, and epoll waits for events from sockets.
>> When i register a new timer in the second thread, ev_loop still waits on
>> epoll...
>>
>
> Of course, this is not allowed.
>
Ok. I redisigned the generation of timeouts and call of callback
functions from one thread.
Thanks.
>
>> To resolve this problem i created a heartbeat timer in the main thread.
>>
>
> It's not a solution, your program will just crash at different times now.
>
> Get a book about threads programming and elarn about race conditions, and how
> to avoid them (e.g. by using a mutex). Also refer to the threads section in
> the libev manual. In short, if you don't lock the loop yourself, then the only
> thing you can do in another thread is to call ev_async_send.
>
>
>> Another solution - is to set timeout on sockets read/write operations.
>>
>
> Not sure what that solves, but you need to understand thread programming
> and use proper locking to avoid races, otherwise your program runs into
> undefined behaviour (most likely, crashes).
>
Now i understand that.
> This is all documented in the libev documentation, however.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20080715/2b838f26/attachment.html>
More information about the libev
mailing list