diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2010-08-06 17:49:37 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-08-25 15:39:20 +0200 |
commit | 05d908492dc382941fc633ad7082b5bd86e84e67 (patch) | |
tree | ae10e49766152e42521a6c100e622dc616998143 /src/session.hpp | |
parent | b7e0fa972f45d21e45cacb93a1a92d38fdc11f40 (diff) |
WIP: Socket migration between threads, new zmq_close() semantics
Sockets may now be migrated between OS threads; sockets may not be used by
more than one thread at any time. To migrate a socket to another thread the
caller must ensure that a full memory barrier is called before using the
socket from the target thread.
The new zmq_close() semantics implement the behaviour discussed at:
http://lists.zeromq.org/pipermail/zeromq-dev/2010-July/004244.html
Specifically, zmq_close() is now deterministic and while it still returns
immediately, it does not discard any data that may still be queued for
sending. Further, zmq_term() will now block until all outstanding data has
been sent.
TODO: Many bugs have been introduced, needs testing. Further, SO_LINGER or
an equivalent mechanism (possibly a configurable timeout to zmq_term())
needs to be implemented.
Diffstat (limited to 'src/session.hpp')
-rw-r--r-- | src/session.hpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/session.hpp b/src/session.hpp index 9bda1ad..603b50c 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -21,15 +21,19 @@ #define __ZMQ_SESSION_HPP_INCLUDED__ #include "i_inout.hpp" -#include "i_endpoint.hpp" #include "owned.hpp" #include "options.hpp" #include "blob.hpp" +#include "pipe.hpp" namespace zmq { - class session_t : public owned_t, public i_inout, public i_endpoint + class session_t : + public owned_t, + public i_inout, + public i_reader_events, + public i_writer_events { public: @@ -50,19 +54,25 @@ namespace zmq class socket_base_t *get_owner (); uint64_t get_ordinal (); - // i_endpoint interface implementation. void attach_pipes (class reader_t *inpipe_, class writer_t *outpipe_, const blob_t &peer_identity_); - void detach_inpipe (class reader_t *pipe_); - void detach_outpipe (class writer_t *pipe_); - void kill (class reader_t *pipe_); - void revive (class reader_t *pipe_); - void revive (class writer_t *pipe_); + + // i_reader_events interface implementation. + void activated (class reader_t *pipe_); + void terminated (class reader_t *pipe_); + + // i_writer_events interface implementation. + void activated (class writer_t *pipe_); + void terminated (class writer_t *pipe_); private: ~session_t (); + // Define the delayed termination. (I.e. termination is postponed + // till all the data is flushed to the kernel.) + bool is_terminable (); + // Handlers for incoming commands. void process_plug (); void process_unplug (); |