Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #466 from hurtonm/code_cleanup

Simplify implementation of DEALER socket
  • Loading branch information...
commit 793895c477cab1da4edd1565d9f70bc8f7d485a8 2 parents d1e0889 + b78800e
@hintjens hintjens authored
Showing with 2 additions and 30 deletions.
  1. +2 −24 src/dealer.cpp
  2. +0 −6 src/dealer.hpp
View
26 src/dealer.cpp
@@ -24,8 +24,7 @@
#include "msg.hpp"
zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
- socket_base_t (parent_, tid_, sid_),
- prefetched (false)
+ socket_base_t (parent_, tid_, sid_)
{
options.type = ZMQ_DEALER;
@@ -34,13 +33,10 @@ zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
// If the socket is closing we can drop all the outbound requests. There'll
// be noone to receive the replies anyway.
// options.delay_on_close = false;
-
- prefetched_msg.init ();
}
zmq::dealer_t::~dealer_t ()
{
- prefetched_msg.close ();
}
void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
@@ -63,30 +59,12 @@ int zmq::dealer_t::xrecv (msg_t *msg_, int flags_)
// flags_ is unused
(void)flags_;
- // If there is a prefetched message, return it.
- if (prefetched) {
- int rc = msg_->move (prefetched_msg);
- errno_assert (rc == 0);
- prefetched = false;
- return 0;
- }
-
return fq.recv (msg_);
}
bool zmq::dealer_t::xhas_in ()
{
- // We may already have a message pre-fetched.
- if (prefetched)
- return true;
-
- // Try to read the next message to the pre-fetch buffer.
- int rc = dealer_t::xrecv (&prefetched_msg, ZMQ_DONTWAIT);
- if (rc != 0 && errno == EAGAIN)
- return false;
- errno_assert (rc == 0);
- prefetched = true;
- return true;
+ return fq.has_in ();
}
bool zmq::dealer_t::xhas_out ()
View
6 src/dealer.hpp
@@ -62,12 +62,6 @@ namespace zmq
fq_t fq;
lb_t lb;
- // Have we prefetched a message.
- bool prefetched;
-
- // Holds the prefetched message.
- msg_t prefetched_msg;
-
dealer_t (const dealer_t&);
const dealer_t &operator = (const dealer_t&);
};
Please sign in to comment.
Something went wrong with that request. Please try again.