On Mon, 2017-12-11 at 11:08 +0000, Stephen Gray wrote:
> I'm developing an app which uses CZMQ on Windows 10.  It's written in
> C++ and uses CZMQ API calls and is compiling and functioning as I had
> hoped, except....
> 
> The app uses a zactor instance which needs to be supplied with a
> function to run.  The function I supply uses a zloop event reactor
> within it.
> 
> Problem is that when invoking zactor_destroy() the program hangs and
> the zloop runs on.  (N.B. The function is monitoring for "$TERM" on
> pipe)
> 
> If I issue CTRL-C from the keyboard then zactor_destroy() will
> complete and the app will shut down smoothly; however what I need is
> that the zactor instance will terminate programmatically on
> zactor_destroy()
> 
> Anyone know how this can be accomplished?
> 
> With thanks.
> 
> Work in progress:   https://pastebin.com/8dyVJZTa

You need to add a zloop_reader for the zactor pipe, and process the
pipe messages (including $TERM) from there. Otherwise your actor is
busy running the zloop and never read the termination message. CTRL-C
works because it sets an interrupted flag.

You can return -1 from a zloop_reader to signal zloop to stop running
and return from zloop_start.

You'll also want to signal the main thread that you are ready just
before going into the loop, rather than before setting everything up,
to avoid race conditions.

-- 
Kind regards,
Luca Boccassi

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to