summaryrefslogtreecommitdiff
path: root/src/dispatcher.cpp
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.cpp
parent2dd501651592baa7f9e49f52e1321ae2b9b4e126 (diff)
pipe deallocation added
Diffstat (limited to 'src/dispatcher.cpp')
-rw-r--r--src/dispatcher.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp
index c0f4541..71e20df 100644
--- a/src/dispatcher.cpp
+++ b/src/dispatcher.cpp
@@ -83,6 +83,10 @@ zmq::dispatcher_t::~dispatcher_t ()
for (io_threads_t::size_type i = 0; i != io_threads.size (); i++)
delete io_threads [i];
+ // Deallocate all the orphaned pipes.
+ for (pipes_t::iterator it = pipes.begin (); it != pipes.end (); it++)
+ delete *it;
+
delete [] command_pipes;
#ifdef ZMQ_HAVE_WINDOWS
@@ -146,3 +150,19 @@ zmq::io_thread_t *zmq::dispatcher_t::choose_io_thread (uint64_t taskset_)
return io_threads [result];
}
+
+void zmq::dispatcher_t::register_pipe (class pipe_t *pipe_)
+{
+ pipes_sync.lock ();
+ bool inserted = pipes.insert (pipe_).second;
+ zmq_assert (inserted);
+ pipes_sync.unlock ();
+}
+
+void zmq::dispatcher_t::unregister_pipe (class pipe_t *pipe_)
+{
+ pipes_sync.lock ();
+ pipes_t::size_type erased = pipes.erase (pipe_);
+ zmq_assert (erased == 1);
+ pipes_sync.unlock ();
+}