From fba28c7c0cddd7c54fe45b38fc38ac6fe5a48438 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 11 Apr 2010 16:36:27 +0200 Subject: issue 1 - Change zmq_term semantics --- src/app_thread.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/app_thread.hpp') diff --git a/src/app_thread.hpp b/src/app_thread.hpp index 9bd5641..1c2f47a 100644 --- a/src/app_thread.hpp +++ b/src/app_thread.hpp @@ -38,14 +38,19 @@ namespace zmq ~app_thread_t (); + // Interrupt blocking call if the app thread is stuck in one. + // This function is is called from a different thread! + void stop (); + // Returns signaler associated with this application thread. struct i_signaler *get_signaler (); // Processes commands sent to this thread (if any). If 'block' is // set to true, returns only after at least one command was processed. // If throttle argument is true, commands are processed at most once - // in a predefined time period. - void process_commands (bool block_, bool throttle_); + // in a predefined time period. The function returns false is the + // associated context was terminated, true otherwise. + bool process_commands (bool block_, bool throttle_); // Create a socket of a specified type. class socket_base_t *create_socket (int type_); @@ -53,8 +58,14 @@ namespace zmq // Unregister the socket from the app_thread (called by socket itself). void remove_socket (class socket_base_t *socket_); + // Returns true is the associated context was already terminated. + bool is_terminated (); + private: + // Command handlers. + void process_stop (); + // All the sockets created from this application thread. typedef yarray_t sockets_t; sockets_t sockets; @@ -65,6 +76,9 @@ namespace zmq // Timestamp of when commands were processed the last time. uint64_t last_processing_time; + // If true, 'stop' command was already received. + bool terminated; + app_thread_t (const app_thread_t&); void operator = (const app_thread_t&); }; -- cgit v1.2.3