From 061d0df60624bdcef571188fd7c7ecdcadf520eb Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:01:02 +0900 Subject: Socket ID added Signed-off-by: Martin Sustrik --- src/ctx.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ctx.cpp') diff --git a/src/ctx.cpp b/src/ctx.cpp index d8783be..54e665a 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2011 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file @@ -180,8 +180,11 @@ zmq::socket_base_t *zmq::ctx_t::create_socket (int type_) uint32_t slot = empty_slots.back (); empty_slots.pop_back (); + // Generate new unique socket ID. + int sid = ((int) max_socket_id.add (1)) + 1; + // Create the socket and register its mailbox. - socket_base_t *s = socket_base_t::create (type_, this, slot); + socket_base_t *s = socket_base_t::create (type_, this, slot, sid); if (!s) { empty_slots.push_back (slot); slot_sync.unlock (); @@ -322,4 +325,6 @@ void zmq::ctx_t::log (const char *format_, va_list args_) errno_assert (rc == 0); } +// The last used socket ID, or 0 if no socket was used so far. +zmq::atomic_counter_t zmq::ctx_t::max_socket_id; -- cgit v1.2.3