summaryrefslogtreecommitdiff
path: root/src/socket_base.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-02-09 22:23:21 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-02-09 22:23:21 +0100
commit5b82b1ba30d136655c72f116ee2e372ded453952 (patch)
tree53ea4a7a075ff52fe75af64b908a04cf9001d39b /src/socket_base.hpp
parent80ac398bba928fa7f245d2e107071677a13185cf (diff)
Reaper thread waits for commands rather them retrieving them periodically
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/socket_base.hpp')
-rw-r--r--src/socket_base.hpp21
1 files changed, 17 insertions, 4 deletions
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;