Commit 9cfdb441 authored by Martin Sustrik's avatar Martin Sustrik

slots renamed to tids

Threads were so far identified by integers called 'slots'.
This patch renames them to more comprehensible 'tid's (thread IDs).
Signed-off-by: 's avatarMartin Sustrik <sustrik@250bpm.com>
parent 623a9c9f
...@@ -92,7 +92,7 @@ zmq::ctx_t::~ctx_t () ...@@ -92,7 +92,7 @@ zmq::ctx_t::~ctx_t ()
for (io_threads_t::size_type i = 0; i != io_threads.size (); i++) for (io_threads_t::size_type i = 0; i != io_threads.size (); i++)
delete io_threads [i]; delete io_threads [i];
// Deallocate the array of slot. No special work is // Deallocate the array of slots. No special work is
// needed as signalers themselves were deallocated with their // needed as signalers themselves were deallocated with their
// corresponding io_thread/socket objects. // corresponding io_thread/socket objects.
free (slots); free (slots);
...@@ -216,9 +216,9 @@ void zmq::ctx_t::zombify_socket (socket_base_t *socket_) ...@@ -216,9 +216,9 @@ void zmq::ctx_t::zombify_socket (socket_base_t *socket_)
slot_sync.unlock (); slot_sync.unlock ();
} }
void zmq::ctx_t::send_command (uint32_t slot_, const command_t &command_) void zmq::ctx_t::send_command (uint32_t tid_, const command_t &command_)
{ {
slots [slot_]->send (command_); slots [tid_]->send (command_);
} }
zmq::io_thread_t *zmq::ctx_t::choose_io_thread (uint64_t affinity_) zmq::io_thread_t *zmq::ctx_t::choose_io_thread (uint64_t affinity_)
...@@ -314,7 +314,7 @@ void zmq::ctx_t::dezombify () ...@@ -314,7 +314,7 @@ void zmq::ctx_t::dezombify ()
// Try to dezombify each zombie in the list. Note that caller is // Try to dezombify each zombie in the list. Note that caller is
// responsible for calling this method in the slot_sync critical section. // responsible for calling this method in the slot_sync critical section.
for (zombies_t::iterator it = zombies.begin (); it != zombies.end ();) { for (zombies_t::iterator it = zombies.begin (); it != zombies.end ();) {
uint32_t slot = (*it)->get_slot (); uint32_t tid = (*it)->get_tid ();
if ((*it)->dezombify ()) { if ((*it)->dezombify ()) {
#if defined _MSC_VER #if defined _MSC_VER
...@@ -323,8 +323,8 @@ void zmq::ctx_t::dezombify () ...@@ -323,8 +323,8 @@ void zmq::ctx_t::dezombify ()
#else #else
zombies.erase (it); zombies.erase (it);
#endif #endif
empty_slots.push_back (slot); empty_slots.push_back (tid);
slots [slot] = NULL; slots [tid] = NULL;
} }
else else
it++; it++;
......
...@@ -61,8 +61,8 @@ namespace zmq ...@@ -61,8 +61,8 @@ namespace zmq
// Make socket a zombie. // Make socket a zombie.
void zombify_socket (socket_base_t *socket_); void zombify_socket (socket_base_t *socket_);
// Send command to the destination slot. // Send command to the destination thread.
void send_command (uint32_t slot_, const command_t &command_); void send_command (uint32_t tid_, const command_t &command_);
// Returns the I/O thread that is the least busy at the moment. // Returns the I/O thread that is the least busy at the moment.
// Affinity specifies which I/O threads are eligible (0 = all). // Affinity specifies which I/O threads are eligible (0 = all).
...@@ -90,7 +90,7 @@ namespace zmq ...@@ -90,7 +90,7 @@ namespace zmq
typedef std::vector <socket_base_t*> zombies_t; typedef std::vector <socket_base_t*> zombies_t;
zombies_t zombies; zombies_t zombies;
// List of unused slots. // List of unused thread slots.
typedef std::vector <uint32_t> emtpy_slots_t; typedef std::vector <uint32_t> emtpy_slots_t;
emtpy_slots_t empty_slots; emtpy_slots_t empty_slots;
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#include "err.hpp" #include "err.hpp"
#include "ctx.hpp" #include "ctx.hpp"
zmq::io_thread_t::io_thread_t (ctx_t *ctx_, uint32_t slot_) : zmq::io_thread_t::io_thread_t (ctx_t *ctx_, uint32_t tid_) :
object_t (ctx_, slot_) object_t (ctx_, tid_)
{ {
poller = new (std::nothrow) poller_t; poller = new (std::nothrow) poller_t;
zmq_assert (poller); zmq_assert (poller);
......
...@@ -38,7 +38,7 @@ namespace zmq ...@@ -38,7 +38,7 @@ namespace zmq
{ {
public: public:
io_thread_t (class ctx_t *ctx_, uint32_t slot_); io_thread_t (class ctx_t *ctx_, uint32_t tid_);
// Clean-up. If the thread was started, it's neccessary to call 'stop' // Clean-up. If the thread was started, it's neccessary to call 'stop'
// before invoking destructor. Otherwise the destructor would hang up. // before invoking destructor. Otherwise the destructor would hang up.
......
...@@ -27,15 +27,15 @@ ...@@ -27,15 +27,15 @@
#include "session.hpp" #include "session.hpp"
#include "socket_base.hpp" #include "socket_base.hpp"
zmq::object_t::object_t (ctx_t *ctx_, uint32_t slot_) : zmq::object_t::object_t (ctx_t *ctx_, uint32_t tid_) :
ctx (ctx_), ctx (ctx_),
slot (slot_) tid (tid_)
{ {
} }
zmq::object_t::object_t (object_t *parent_) : zmq::object_t::object_t (object_t *parent_) :
ctx (parent_->ctx), ctx (parent_->ctx),
slot (parent_->slot) tid (parent_->tid)
{ {
} }
...@@ -43,9 +43,9 @@ zmq::object_t::~object_t () ...@@ -43,9 +43,9 @@ zmq::object_t::~object_t ()
{ {
} }
uint32_t zmq::object_t::get_slot () uint32_t zmq::object_t::get_tid ()
{ {
return slot; return tid;
} }
zmq::ctx_t *zmq::object_t::get_ctx () zmq::ctx_t *zmq::object_t::get_ctx ()
...@@ -162,7 +162,7 @@ void zmq::object_t::send_stop () ...@@ -162,7 +162,7 @@ void zmq::object_t::send_stop ()
#endif #endif
cmd.destination = this; cmd.destination = this;
cmd.type = command_t::stop; cmd.type = command_t::stop;
ctx->send_command (slot, cmd); ctx->send_command (tid, cmd);
} }
void zmq::object_t::send_plug (own_t *destination_, bool inc_seqnum_) void zmq::object_t::send_plug (own_t *destination_, bool inc_seqnum_)
...@@ -404,6 +404,6 @@ void zmq::object_t::process_seqnum () ...@@ -404,6 +404,6 @@ void zmq::object_t::process_seqnum ()
void zmq::object_t::send_command (command_t &cmd_) void zmq::object_t::send_command (command_t &cmd_)
{ {
ctx->send_command (cmd_.destination->get_slot (), cmd_); ctx->send_command (cmd_.destination->get_tid (), cmd_);
} }
...@@ -34,11 +34,11 @@ namespace zmq ...@@ -34,11 +34,11 @@ namespace zmq
{ {
public: public:
object_t (class ctx_t *ctx_, uint32_t slot_); object_t (class ctx_t *ctx_, uint32_t tid_);
object_t (object_t *parent_); object_t (object_t *parent_);
virtual ~object_t (); virtual ~object_t ();
uint32_t get_slot (); uint32_t get_tid ();
ctx_t *get_ctx (); ctx_t *get_ctx ();
void process_command (struct command_t &cmd_); void process_command (struct command_t &cmd_);
...@@ -110,8 +110,8 @@ namespace zmq ...@@ -110,8 +110,8 @@ namespace zmq
// Context provides access to the global state. // Context provides access to the global state.
class ctx_t *ctx; class ctx_t *ctx;
// Slot ID of the thread the object belongs to. // Thread ID of the thread the object belongs to.
uint32_t slot; uint32_t tid;
void send_command (command_t &cmd_); void send_command (command_t &cmd_);
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include "err.hpp" #include "err.hpp"
#include "io_thread.hpp" #include "io_thread.hpp"
zmq::own_t::own_t (class ctx_t *parent_, uint32_t slot_) : zmq::own_t::own_t (class ctx_t *parent_, uint32_t tid_) :
object_t (parent_, slot_), object_t (parent_, tid_),
terminating (false), terminating (false),
sent_seqnum (0), sent_seqnum (0),
processed_seqnum (0), processed_seqnum (0),
......
...@@ -43,7 +43,7 @@ namespace zmq ...@@ -43,7 +43,7 @@ namespace zmq
// The object is not living within an I/O thread. It has it's own // The object is not living within an I/O thread. It has it's own
// thread outside of 0MQ infrastructure. // thread outside of 0MQ infrastructure.
own_t (class ctx_t *parent_, uint32_t slot_); own_t (class ctx_t *parent_, uint32_t tid_);
// The object is living within I/O thread. // The object is living within I/O thread.
own_t (class io_thread_t *io_thread_, const options_t &options_); own_t (class io_thread_t *io_thread_, const options_t &options_);
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "err.hpp" #include "err.hpp"
#include "pipe.hpp" #include "pipe.hpp"
zmq::pair_t::pair_t (class ctx_t *parent_, uint32_t slot_) : zmq::pair_t::pair_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
inpipe (NULL), inpipe (NULL),
outpipe (NULL), outpipe (NULL),
inpipe_alive (false), inpipe_alive (false),
......
...@@ -33,7 +33,7 @@ namespace zmq ...@@ -33,7 +33,7 @@ namespace zmq
{ {
public: public:
pair_t (class ctx_t *parent_, uint32_t slot_); pair_t (class ctx_t *parent_, uint32_t tid_);
~pair_t (); ~pair_t ();
// Overloads of functions from socket_base_t. // Overloads of functions from socket_base_t.
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "msg_content.hpp" #include "msg_content.hpp"
#include "pipe.hpp" #include "pipe.hpp"
zmq::pub_t::pub_t (class ctx_t *parent_, uint32_t slot_) : zmq::pub_t::pub_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
active (0), active (0),
terminating (false) terminating (false)
{ {
......
...@@ -31,7 +31,7 @@ namespace zmq ...@@ -31,7 +31,7 @@ namespace zmq
{ {
public: public:
pub_t (class ctx_t *parent_, uint32_t slot_); pub_t (class ctx_t *parent_, uint32_t tid_);
~pub_t (); ~pub_t ();
// Implementations of virtual functions from socket_base_t. // Implementations of virtual functions from socket_base_t.
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "pull.hpp" #include "pull.hpp"
#include "err.hpp" #include "err.hpp"
zmq::pull_t::pull_t (class ctx_t *parent_, uint32_t slot_) : zmq::pull_t::pull_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
fq (this) fq (this)
{ {
options.type = ZMQ_PULL; options.type = ZMQ_PULL;
......
...@@ -30,7 +30,7 @@ namespace zmq ...@@ -30,7 +30,7 @@ namespace zmq
{ {
public: public:
pull_t (class ctx_t *parent_, uint32_t slot_); pull_t (class ctx_t *parent_, uint32_t tid_);
~pull_t (); ~pull_t ();
protected: protected:
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "err.hpp" #include "err.hpp"
#include "pipe.hpp" #include "pipe.hpp"
zmq::push_t::push_t (class ctx_t *parent_, uint32_t slot_) : zmq::push_t::push_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
lb (this) lb (this)
{ {
options.type = ZMQ_PUSH; options.type = ZMQ_PUSH;
......
...@@ -30,7 +30,7 @@ namespace zmq ...@@ -30,7 +30,7 @@ namespace zmq
{ {
public: public:
push_t (class ctx_t *parent_, uint32_t slot_); push_t (class ctx_t *parent_, uint32_t tid_);
~push_t (); ~push_t ();
protected: protected:
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "rep.hpp" #include "rep.hpp"
#include "err.hpp" #include "err.hpp"
zmq::rep_t::rep_t (class ctx_t *parent_, uint32_t slot_) : zmq::rep_t::rep_t (class ctx_t *parent_, uint32_t tid_) :
xrep_t (parent_, slot_), xrep_t (parent_, tid_),
sending_reply (false), sending_reply (false),
request_begins (true) request_begins (true)
{ {
......
...@@ -29,7 +29,7 @@ namespace zmq ...@@ -29,7 +29,7 @@ namespace zmq
{ {
public: public:
rep_t (class ctx_t *parent_, uint32_t slot_); rep_t (class ctx_t *parent_, uint32_t tid_);
~rep_t (); ~rep_t ();
// Overloads of functions from socket_base_t. // Overloads of functions from socket_base_t.
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "req.hpp" #include "req.hpp"
#include "err.hpp" #include "err.hpp"
zmq::req_t::req_t (class ctx_t *parent_, uint32_t slot_) : zmq::req_t::req_t (class ctx_t *parent_, uint32_t tid_) :
xreq_t (parent_, slot_), xreq_t (parent_, tid_),
receiving_reply (false), receiving_reply (false),
message_begins (true) message_begins (true)
{ {
......
...@@ -29,7 +29,7 @@ namespace zmq ...@@ -29,7 +29,7 @@ namespace zmq
{ {
public: public:
req_t (class ctx_t *parent_, uint32_t slot_); req_t (class ctx_t *parent_, uint32_t tid_);
~req_t (); ~req_t ();
// Overloads of functions from socket_base_t. // Overloads of functions from socket_base_t.
......
...@@ -58,37 +58,37 @@ ...@@ -58,37 +58,37 @@
#include "uuid.hpp" #include "uuid.hpp"
zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_, zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,
uint32_t slot_) uint32_t tid_)
{ {
socket_base_t *s = NULL; socket_base_t *s = NULL;
switch (type_) { switch (type_) {
case ZMQ_PAIR: case ZMQ_PAIR:
s = new (std::nothrow) pair_t (parent_, slot_); s = new (std::nothrow) pair_t (parent_, tid_);
break; break;
case ZMQ_PUB: case ZMQ_PUB:
s = new (std::nothrow) pub_t (parent_, slot_); s = new (std::nothrow) pub_t (parent_, tid_);
break; break;
case ZMQ_SUB: case ZMQ_SUB:
s = new (std::nothrow) sub_t (parent_, slot_); s = new (std::nothrow) sub_t (parent_, tid_);
break; break;
case ZMQ_REQ: case ZMQ_REQ:
s = new (std::nothrow) req_t (parent_, slot_); s = new (std::nothrow) req_t (parent_, tid_);
break; break;
case ZMQ_REP: case ZMQ_REP:
s = new (std::nothrow) rep_t (parent_, slot_); s = new (std::nothrow) rep_t (parent_, tid_);
break; break;
case ZMQ_XREQ: case ZMQ_XREQ:
s = new (std::nothrow) xreq_t (parent_, slot_); s = new (std::nothrow) xreq_t (parent_, tid_);
break; break;
case ZMQ_XREP: case ZMQ_XREP:
s = new (std::nothrow) xrep_t (parent_, slot_); s = new (std::nothrow) xrep_t (parent_, tid_);
break; break;
case ZMQ_PULL: case ZMQ_PULL:
s = new (std::nothrow) pull_t (parent_, slot_); s = new (std::nothrow) pull_t (parent_, tid_);
break; break;
case ZMQ_PUSH: case ZMQ_PUSH:
s = new (std::nothrow) push_t (parent_, slot_); s = new (std::nothrow) push_t (parent_, tid_);
break; break;
default: default:
errno = EINVAL; errno = EINVAL;
...@@ -98,8 +98,8 @@ zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_, ...@@ -98,8 +98,8 @@ zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,
return s; return s;
} }
zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t slot_) : zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_) :
own_t (parent_, slot_), own_t (parent_, tid_),
ctx_terminated (false), ctx_terminated (false),
destroyed (false), destroyed (false),
last_tsc (0), last_tsc (0),
......
...@@ -46,7 +46,7 @@ namespace zmq ...@@ -46,7 +46,7 @@ namespace zmq
// Create a socket of a specified type. // Create a socket of a specified type.
static socket_base_t *create (int type_, class ctx_t *parent_, static socket_base_t *create (int type_, class ctx_t *parent_,
uint32_t slot_); uint32_t tid_);
// Returns the signaler associated with this socket. // Returns the signaler associated with this socket.
signaler_t *get_signaler (); signaler_t *get_signaler ();
...@@ -88,7 +88,7 @@ namespace zmq ...@@ -88,7 +88,7 @@ namespace zmq
protected: protected:
socket_base_t (class ctx_t *parent_, uint32_t slot_); socket_base_t (class ctx_t *parent_, uint32_t tid_);
virtual ~socket_base_t (); virtual ~socket_base_t ();
// Concrete algorithms for the x- methods are to be defined by // Concrete algorithms for the x- methods are to be defined by
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "sub.hpp" #include "sub.hpp"
#include "err.hpp" #include "err.hpp"
zmq::sub_t::sub_t (class ctx_t *parent_, uint32_t slot_) : zmq::sub_t::sub_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
fq (this), fq (this),
has_message (false), has_message (false),
more (false) more (false)
......
...@@ -33,7 +33,7 @@ namespace zmq ...@@ -33,7 +33,7 @@ namespace zmq
{ {
public: public:
sub_t (class ctx_t *parent_, uint32_t slot_); sub_t (class ctx_t *parent_, uint32_t tid_);
~sub_t (); ~sub_t ();
protected: protected:
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "err.hpp" #include "err.hpp"
#include "pipe.hpp" #include "pipe.hpp"
zmq::xrep_t::xrep_t (class ctx_t *parent_, uint32_t slot_) : zmq::xrep_t::xrep_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
current_in (0), current_in (0),
prefetched (false), prefetched (false),
more_in (false), more_in (false),
......
...@@ -38,7 +38,7 @@ namespace zmq ...@@ -38,7 +38,7 @@ namespace zmq
{ {
public: public:
xrep_t (class ctx_t *parent_, uint32_t slot_); xrep_t (class ctx_t *parent_, uint32_t tid_);
~xrep_t (); ~xrep_t ();
// Overloads of functions from socket_base_t. // Overloads of functions from socket_base_t.
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "xreq.hpp" #include "xreq.hpp"
#include "err.hpp" #include "err.hpp"
zmq::xreq_t::xreq_t (class ctx_t *parent_, uint32_t slot_) : zmq::xreq_t::xreq_t (class ctx_t *parent_, uint32_t tid_) :
socket_base_t (parent_, slot_), socket_base_t (parent_, tid_),
fq (this), fq (this),
lb (this) lb (this)
{ {
......
...@@ -31,7 +31,7 @@ namespace zmq ...@@ -31,7 +31,7 @@ namespace zmq
{ {
public: public:
xreq_t (class ctx_t *parent_, uint32_t slot_); xreq_t (class ctx_t *parent_, uint32_t tid_);
~xreq_t (); ~xreq_t ();
protected: protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment