Why can't I get this two-way ev_async example to work?

Marc Lehmann schmorp at schmorp.de
Fri Nov 22 18:15:20 CET 2013


On Fri, Nov 22, 2013 at 10:04:38PM +0800, Åke Kullenberg <ake.kullenberg at gmail.com> wrote:
> However when I run the program the slave thread's call to ev_async_send
> doesn't seem to register. The callback to master_cb_async is never invoked.
> 
> static void slave_cb_timeout(EV_P_ ev_timer *w, int revents) {
>         if (ev_async_pending(&async_to_master) == 0) {
>                 printf("    %s - sending async_send to loop\n", FUNC);
>                 ev_async_send(loop, &async_to_master);

The "loop" you refer to here is the parameter "loop" that EV_P_ declares.

If you change the last line to:

                extern struct ev_loop *loop;
                ev_async_send(loop, &async_to_master);

Then it should work (less ugly solution: rename the outer loop variable to
"loop1").

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