so, I should use an extra ev_async to call ev_feed_event for that ev_timer? 
This ev_async in the same thread, and call ev_feed_event in its callback. 

发送自HTC手机

----- Reply message -----
发件人: "Marc Lehmann" <[email protected]>
收件人: "钱晓明" <[email protected]>
抄送: "libev" <[email protected]>
主题: Is it safe to call ev_feed_event on an ev_timer in different thread?
日期: 周一, 8 月 27 日, 2012 年 12:50


On Sun, Aug 26, 2012 at 09:55:42PM +0800, 钱晓明 <[email protected]> wrote:
> Hi, is ev_feed_event is thread safe?

As long as you call it on the same loop only in one thread at a time, yes.

> I have an ev_timer installed in a loop within main thread, can I call
> ev_feed_event in another thread to simulate the time out event?

Not without locking the event loop, e.g. with a mutex (you could use the
acquire/release callbacks and an ev_async watcher to lock/unlock and wake
up the loop).

> Is it safe?

Without proper locking, no, it will most likely corrupt libev's internal
data structures and not even work.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      [email protected]
      -=====/_/_//_/\_,_/ /_/\_\
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to