From aebff623f36efddc0de7a3192832b61802f8cec8 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Wed, 23 Dec 2009 19:37:56 +0100 Subject: ZMQII-28: Bidirectional introduction on TCP connection establishment --- src/socket_base.hpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/socket_base.hpp') diff --git a/src/socket_base.hpp b/src/socket_base.hpp index 79a8340..16553ea 100644 --- a/src/socket_base.hpp +++ b/src/socket_base.hpp @@ -34,6 +34,7 @@ #include "options.hpp" #include "stdint.hpp" #include "atomic_counter.hpp" +#include "stdint.hpp" namespace zmq { @@ -74,9 +75,15 @@ namespace zmq // commands as it is unacceptable to wait for the completion of the // action till user application yields control of the application // thread to 0MQ. Locking is used instead. + // There are two distinct types of sessions: those identified by name + // and those identified by ordinal number. Thus two sets of session + // management functions. bool register_session (const char *name_, class session_t *session_); - bool unregister_session (const char *name_); + void unregister_session (const char *name_); class session_t *find_session (const char *name_); + uint64_t register_session (class session_t *session_); + void unregister_session (uint64_t ordinal_); + class session_t *find_session (uint64_t ordinal_); // i_endpoint interface implementation. void attach_pipes (class reader_t *inpipe_, class writer_t *outpipe_); @@ -144,15 +151,15 @@ namespace zmq // Sequence number of the last command processed by this object. uint64_t processed_seqnum; - // List of existing sessions. This list is never referenced from within - // the socket, instead it is used by I/O objects owned by the session. - // As those objects can live in different threads, the access is - // synchronised using 'sessions_sync' mutex. - // Local sessions are those named by the local instance of 0MQ. - // Remote sessions are the sessions who's identities are provided by - // the remote party. - typedef std::map sessions_t; - sessions_t sessions; + // Lists of existing sessions. This lists are never referenced from + // within the socket, instead they are used by I/O objects owned by + // the socket. As those objects can live in different threads, + // the access is synchronised by mutex. + typedef std::map named_sessions_t; + named_sessions_t named_sessions; + typedef std::map unnamed_sessions_t; + unnamed_sessions_t unnamed_sessions; + uint64_t next_ordinal; mutex_t sessions_sync; socket_base_t (const socket_base_t&); -- cgit v1.2.3