Optimise block/non-block switching in mailbox_t

For the platforms that don't support MSG_DONTWAIT the reader
socket in mailbox_t was kept in non-blocking state and flipped
to blocking state and back when blocking read was requested.
Now, the state is preserved between calls and flipped only
if different type of operation (block vs. non-block) is
requested.

Signed-off-by: Fabien Ninoles <fabien@tzone.org>
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
Fabien Ninoles
2011-06-20 08:14:21 +02:00
committed by Martin Sustrik
parent 8440de2b14
commit 7572fee979
2 changed files with 23 additions and 60 deletions

View File

@@ -45,10 +45,6 @@ namespace zmq
private:
// Write & read end of the socketpair.
fd_t w;
fd_t r;
// Platform-dependent function to create a socketpair.
static int make_socketpair (fd_t *r_, fd_t *w_);
@@ -57,6 +53,14 @@ namespace zmq
// blocking recvs.
int recv_timeout (command_t *cmd_, int timeout_);
// Write & read end of the socketpair.
fd_t w;
fd_t r;
// Used on platforms where there's no MSG_DONTWAIT functionality.
// True if the read socket is set to the blocking state.
bool blocking;
// Disable copying of mailbox_t object.
mailbox_t (const mailbox_t&);
const mailbox_t &operator = (const mailbox_t&);