summaryrefslogtreecommitdiff
path: root/src/dispatcher.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-08-28 16:51:46 +0200
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-08-28 16:51:46 +0200
commitcb09c6951e2c4405318b422a1f9213af3e4b6b8a (patch)
treefb5d4dfd6a71745e885b2501f19cfbbb38c6f441 /src/dispatcher.hpp
parent2dd501651592baa7f9e49f52e1321ae2b9b4e126 (diff)
pipe deallocation added
Diffstat (limited to 'src/dispatcher.hpp')
-rw-r--r--src/dispatcher.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/dispatcher.hpp b/src/dispatcher.hpp
index 08596cb..cb445ef 100644
--- a/src/dispatcher.hpp
+++ b/src/dispatcher.hpp
@@ -21,6 +21,7 @@
#define __ZMQ_DISPATCHER_HPP_INCLUDED__
#include <vector>
+#include <set>
#include <map>
#include <string>
@@ -85,6 +86,11 @@ namespace zmq
// Taskset specifies which I/O threads are eligible (0 = all).
class io_thread_t *choose_io_thread (uint64_t taskset_);
+ // All pipes are registered with the dispatcher so that even the
+ // orphaned pipes can be deallocated on the terminal shutdown.
+ void register_pipe (class pipe_t *pipe_);
+ void unregister_pipe (class pipe_t *pipe_);
+
private:
// Returns the app thread associated with the current thread.
@@ -112,6 +118,18 @@ namespace zmq
// Synchronisation of accesses to shared thread data.
mutex_t threads_sync;
+ // As pipes may reside in orphaned state in particular moments
+ // of the pipe shutdown process, i.e. neither pipe reader nor
+ // pipe writer hold reference to the pipe, we have to hold references
+ // to all pipes in dispatcher so that we can deallocate them
+ // during terminal shutdown even though it conincides with the
+ // pipe being in the orphaned state.
+ typedef std::set <class pipe_t*> pipes_t;
+ pipes_t pipes;
+
+ // Synchronisation of access to the pipes repository.
+ mutex_t pipes_sync;
+
dispatcher_t (const dispatcher_t&);
void operator = (const dispatcher_t&);
};