From 27e47bdcc0358b84a57378e19359556e2dbcb50e Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 2 Feb 2010 13:29:31 +0100 Subject: ZMQII-54: Affinity isn't honoured --- src/dispatcher.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp index b830654..806866c 100644 --- a/src/dispatcher.cpp +++ b/src/dispatcher.cpp @@ -176,23 +176,22 @@ zmq::app_thread_t *zmq::dispatcher_t::choose_app_thread () return NULL; } -zmq::io_thread_t *zmq::dispatcher_t::choose_io_thread (uint64_t taskset_) +zmq::io_thread_t *zmq::dispatcher_t::choose_io_thread (uint64_t affinity_) { - zmq_assert (io_threads.size () > 0); - // Find the I/O thread with minimum load. - int min_load = io_threads [0]->get_load (); + zmq_assert (io_threads.size () > 0); + int min_load = -1; io_threads_t::size_type result = 0; - for (io_threads_t::size_type i = 1; i != io_threads.size (); i++) { - if (!taskset_ || (taskset_ & (uint64_t (1) << i))) { + for (io_threads_t::size_type i = 0; i != io_threads.size (); i++) { + if (!affinity_ || (affinity_ & (uint64_t (1) << i))) { int load = io_threads [i]->get_load (); - if (load < min_load) { + if (min_load == -1 || load < min_load) { min_load = load; result = i; } } } - + zmq_assert (min_load != -1); return io_threads [result]; } -- cgit v1.2.3