diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2010-04-29 20:34:48 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-04-29 20:34:48 +0200 |
commit | ae93ed318a450d6d763a5f629d478467f7362b07 (patch) | |
tree | 096abe5592237e31ab4d85d71b567e42d44889d4 /src/app_thread.cpp | |
parent | 1ffc6dd41f2e2ce45c67f3fe08780c5a09cf667d (diff) |
signaler rewritten in such a way that any number (>64) of threads can be used
Diffstat (limited to 'src/app_thread.cpp')
-rw-r--r-- | src/app_thread.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/app_thread.cpp b/src/app_thread.cpp index 10068c0..1350248 100644 --- a/src/app_thread.cpp +++ b/src/app_thread.cpp @@ -57,7 +57,8 @@ #define ZMQ_DELAY_COMMANDS #endif -zmq::app_thread_t::app_thread_t (dispatcher_t *dispatcher_, int thread_slot_) : +zmq::app_thread_t::app_thread_t (dispatcher_t *dispatcher_, + uint32_t thread_slot_) : object_t (dispatcher_, thread_slot_), last_processing_time (0), terminated (false) @@ -81,9 +82,9 @@ zmq::signaler_t *zmq::app_thread_t::get_signaler () bool zmq::app_thread_t::process_commands (bool block_, bool throttle_) { - uint64_t signals; + uint32_t signal; if (block_) - signals = signaler.poll (); + signal = signaler.poll (); else { #if defined ZMQ_DELAY_COMMANDS @@ -116,20 +117,14 @@ bool zmq::app_thread_t::process_commands (bool block_, bool throttle_) #endif // Check whether there are any commands pending for this thread. - signals = signaler.check (); + signal = signaler.check (); } - if (signals) { - - // Traverse all the possible sources of commands and process - // all the commands from all of them. - for (int i = 0; i != thread_slot_count (); i++) { - if (signals & (uint64_t (1) << i)) { - command_t cmd; - while (dispatcher->read (i, get_thread_slot (), &cmd)) - cmd.destination->process_command (cmd); - } - } + // Process all the commands from the signaling source if there is one. + if (signal != signaler_t::no_signal) { + command_t cmd; + while (dispatcher->read (signal, get_thread_slot (), &cmd)) + cmd.destination->process_command (cmd); } return !terminated; |