From 5b82b1ba30d136655c72f116ee2e372ded453952 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Wed, 9 Feb 2011 22:23:21 +0100 Subject: Reaper thread waits for commands rather them retrieving them periodically Signed-off-by: Martin Sustrik --- src/socket_base.hpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/socket_base.hpp') diff --git a/src/socket_base.hpp b/src/socket_base.hpp index a74b7d0..cea5bc8 100644 --- a/src/socket_base.hpp +++ b/src/socket_base.hpp @@ -29,7 +29,9 @@ #include "array.hpp" #include "mutex.hpp" #include "stdint.hpp" +#include "poller.hpp" #include "atomic_counter.hpp" +#include "i_poll_events.hpp" #include "mailbox.hpp" #include "stdint.hpp" #include "blob.hpp" @@ -40,7 +42,8 @@ namespace zmq class socket_base_t : public own_t, - public array_item_t + public array_item_t, + public i_poll_events { friend class reaper_t; @@ -84,9 +87,15 @@ namespace zmq void activated (class writer_t *pipe_); void terminated (class writer_t *pipe_); - // This function should be called only on sockets that are already - // closed -- from the reaper thread. It tries to finalise the socket. - bool reap (); + // Using this function reaper thread ask the socket to regiter with + // its poller. + void start_reaping (poller_t *poller_); + + // i_poll_events implementation. This interface is used when socket + // is handled by the poller in the reaper thread. + void in_event (); + void out_event (); + void timer_event (int id_); protected: @@ -157,6 +166,10 @@ namespace zmq // Socket's mailbox object. mailbox_t mailbox; + // Reaper's poller and handle of this socket within it. + poller_t *poller; + poller_t::handle_t handle; + // Timestamp of when commands were processed the last time. uint64_t last_tsc; -- cgit v1.2.3