summaryrefslogtreecommitdiff
path: root/src/mailbox.hpp
diff options
context:
space:
mode:
authorMartin Lucina <martin@lucina.net>2012-01-23 08:54:14 +0100
committerMartin Lucina <martin@lucina.net>2012-01-23 08:54:14 +0100
commit75af6aed482ab16997c1388fe801f74d11ec12a4 (patch)
tree637249631acc81446f6b5c2e25223f3164e132f6 /src/mailbox.hpp
parentb593ea30833ad5dcacb9076c988aec31b0cf26ec (diff)
Imported Upstream version 2.1.9upstream/2.1.9
Diffstat (limited to 'src/mailbox.hpp')
-rw-r--r--src/mailbox.hpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/mailbox.hpp b/src/mailbox.hpp
index 96bf4eb..0675b99 100644
--- a/src/mailbox.hpp
+++ b/src/mailbox.hpp
@@ -24,10 +24,12 @@
#include <stddef.h>
#include "platform.hpp"
+#include "signaler.hpp"
#include "fd.hpp"
-#include "stdint.hpp"
#include "config.hpp"
#include "command.hpp"
+#include "ypipe.hpp"
+#include "mutex.hpp"
namespace zmq
{
@@ -41,16 +43,26 @@ namespace zmq
fd_t get_fd ();
void send (const command_t &cmd_);
- int recv (command_t *cmd_, bool block_);
+ int recv (command_t *cmd_, int timeout_);
private:
- // Write & read end of the socketpair.
- fd_t w;
- fd_t r;
+ // The pipe to store actual commands.
+ typedef ypipe_t <command_t, command_pipe_granularity> cpipe_t;
+ cpipe_t cpipe;
- // Platform-dependent function to create a socketpair.
- static int make_socketpair (fd_t *r_, fd_t *w_);
+ // Signaler to pass signals from writer thread to reader thread.
+ signaler_t signaler;
+
+ // There's only one thread receiving from the mailbox, but there
+ // is arbitrary number of threads sending. Given that ypipe requires
+ // synchronised access on both of its endpoints, we have to synchronise
+ // the sending side.
+ mutex_t sync;
+
+ // True if the underlying pipe is active, ie. when we are allowed to
+ // read commands from it.
+ bool active;
// Disable copying of mailbox_t object.
mailbox_t (const mailbox_t&);