summaryrefslogtreecommitdiff
path: root/src/app_thread.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/app_thread.cpp
parentdff79d778db46bebe1e3b0cbd28b328972b9adb8 (diff)
issue 1 - Change zmq_term semantics
Diffstat (limited to 'src/app_thread.cpp')
-rw-r--r--src/app_thread.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/app_thread.cpp b/src/app_thread.cpp
index 61e49e5..6141c06 100644
--- a/src/app_thread.cpp
+++ b/src/app_thread.cpp
@@ -62,7 +62,8 @@
zmq::app_thread_t::app_thread_t (dispatcher_t *dispatcher_, int thread_slot_,
int flags_) :
object_t (dispatcher_, thread_slot_),
- last_processing_time (0)
+ last_processing_time (0),
+ terminated (false)
{
if (flags_ & ZMQ_POLL) {
signaler = new (std::nothrow) fd_signaler_t;
@@ -81,12 +82,17 @@ zmq::app_thread_t::~app_thread_t ()
delete signaler;
}
+void zmq::app_thread_t::stop ()
+{
+ send_stop ();
+}
+
zmq::i_signaler *zmq::app_thread_t::get_signaler ()
{
return signaler;
}
-void zmq::app_thread_t::process_commands (bool block_, bool throttle_)
+bool zmq::app_thread_t::process_commands (bool block_, bool throttle_)
{
uint64_t signals;
if (block_)
@@ -117,7 +123,7 @@ void zmq::app_thread_t::process_commands (bool block_, bool throttle_)
// Check whether certain time have elapsed since last command
// processing.
if (current_time - last_processing_time <= max_command_delay)
- return;
+ return !terminated;
last_processing_time = current_time;
}
#endif
@@ -138,6 +144,8 @@ void zmq::app_thread_t::process_commands (bool block_, bool throttle_)
}
}
}
+
+ return !terminated;
}
zmq::socket_base_t *zmq::app_thread_t::create_socket (int type_)
@@ -190,3 +198,14 @@ void zmq::app_thread_t::remove_socket (socket_base_t *socket_)
if (sockets.empty ())
dispatcher->no_sockets (this);
}
+
+void zmq::app_thread_t::process_stop ()
+{
+ terminated = true;
+}
+
+bool zmq::app_thread_t::is_terminated ()
+{
+ return terminated;
+}
+