mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 10:32:58 +01:00
signaler rewritten in such a way that any number (>64) of threads can be used
This commit is contained in:
@@ -28,7 +28,8 @@
|
||||
#include "command.hpp"
|
||||
#include "dispatcher.hpp"
|
||||
|
||||
zmq::io_thread_t::io_thread_t (dispatcher_t *dispatcher_, int thread_slot_) :
|
||||
zmq::io_thread_t::io_thread_t (dispatcher_t *dispatcher_,
|
||||
uint32_t thread_slot_) :
|
||||
object_t (dispatcher_, thread_slot_)
|
||||
{
|
||||
poller = new (std::nothrow) poller_t;
|
||||
@@ -66,22 +67,17 @@ int zmq::io_thread_t::get_load ()
|
||||
|
||||
void zmq::io_thread_t::in_event ()
|
||||
{
|
||||
// Find out which threads are sending us commands.
|
||||
uint64_t signals = signaler.check ();
|
||||
zmq_assert (signals);
|
||||
while (true) {
|
||||
|
||||
// Iterate through all the threads in the process and find out
|
||||
// which of them sent us commands.
|
||||
int slot_count = thread_slot_count ();
|
||||
for (int source_thread_slot = 0;
|
||||
source_thread_slot != slot_count; source_thread_slot++) {
|
||||
if (signals & (uint64_t (1) << source_thread_slot)) {
|
||||
// Get the next signal.
|
||||
uint32_t signal = signaler.check ();
|
||||
if (signal == signaler_t::no_signal)
|
||||
break;
|
||||
|
||||
// Read all the commands from particular thread.
|
||||
command_t cmd;
|
||||
while (dispatcher->read (source_thread_slot, thread_slot, &cmd))
|
||||
cmd.destination->process_command (cmd);
|
||||
}
|
||||
// Process all the commands from the thread that sent the signal.
|
||||
command_t cmd;
|
||||
while (dispatcher->read (signal, thread_slot, &cmd))
|
||||
cmd.destination->process_command (cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user