summaryrefslogtreecommitdiff
path: root/src/dispatcher.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-04-11 16:36:27 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-04-11 16:36:27 +0200
commitfba28c7c0cddd7c54fe45b38fc38ac6fe5a48438 (patch)
treeed03da45d220b24f384f2a2d9b33882e322317b8 /src/dispatcher.cpp
parentdff79d778db46bebe1e3b0cbd28b328972b9adb8 (diff)
issue 1 - Change zmq_term semantics
Diffstat (limited to 'src/dispatcher.cpp')
-rw-r--r--src/dispatcher.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp
index 93c5db3..a1154de 100644
--- a/src/dispatcher.cpp
+++ b/src/dispatcher.cpp
@@ -86,12 +86,19 @@ zmq::dispatcher_t::dispatcher_t (int app_threads_, int io_threads_,
int zmq::dispatcher_t::term ()
{
+ // First send stop command to application threads so that any
+ // blocking calls are interrupted.
+ for (app_threads_t::size_type i = 0; i != app_threads.size (); i++)
+ app_threads [i].app_thread->stop ();
+
+ // Then mark context as terminated.
term_sync.lock ();
zmq_assert (!terminated);
terminated = true;
bool destroy = (sockets == 0);
term_sync.unlock ();
+ // If there are no sockets open, destroy the context immediately.
if (destroy)
delete this;