Skip to content
This repository
Browse code

Merge pull request #466 from hurtonm/code_cleanup

Simplify implementation of DEALER socket
  • Loading branch information...
commit 793895c477cab1da4edd1565d9f70bc8f7d485a8 2 parents d1e0889 + b78800e
Pieter Hintjens hintjens authored

Showing 2 changed files with 2 additions and 30 deletions. Show diff stats Hide diff stats

  1. +2 24 src/dealer.cpp
  2. +0 6 src/dealer.hpp
26 src/dealer.cpp
@@ -24,8 +24,7 @@
24 24 #include "msg.hpp"
25 25
26 26 zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
27   - socket_base_t (parent_, tid_, sid_),
28   - prefetched (false)
  27 + socket_base_t (parent_, tid_, sid_)
29 28 {
30 29 options.type = ZMQ_DEALER;
31 30
@@ -34,13 +33,10 @@ zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
34 33 // If the socket is closing we can drop all the outbound requests. There'll
35 34 // be noone to receive the replies anyway.
36 35 // options.delay_on_close = false;
37   -
38   - prefetched_msg.init ();
39 36 }
40 37
41 38 zmq::dealer_t::~dealer_t ()
42 39 {
43   - prefetched_msg.close ();
44 40 }
45 41
46 42 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_)
63 59 // flags_ is unused
64 60 (void)flags_;
65 61
66   - // If there is a prefetched message, return it.
67   - if (prefetched) {
68   - int rc = msg_->move (prefetched_msg);
69   - errno_assert (rc == 0);
70   - prefetched = false;
71   - return 0;
72   - }
73   -
74 62 return fq.recv (msg_);
75 63 }
76 64
77 65 bool zmq::dealer_t::xhas_in ()
78 66 {
79   - // We may already have a message pre-fetched.
80   - if (prefetched)
81   - return true;
82   -
83   - // Try to read the next message to the pre-fetch buffer.
84   - int rc = dealer_t::xrecv (&prefetched_msg, ZMQ_DONTWAIT);
85   - if (rc != 0 && errno == EAGAIN)
86   - return false;
87   - errno_assert (rc == 0);
88   - prefetched = true;
89   - return true;
  67 + return fq.has_in ();
90 68 }
91 69
92 70 bool zmq::dealer_t::xhas_out ()
6 src/dealer.hpp
@@ -62,12 +62,6 @@ namespace zmq
62 62 fq_t fq;
63 63 lb_t lb;
64 64
65   - // Have we prefetched a message.
66   - bool prefetched;
67   -
68   - // Holds the prefetched message.
69   - msg_t prefetched_msg;
70   -
71 65 dealer_t (const dealer_t&);
72 66 const dealer_t &operator = (const dealer_t&);
73 67 };

0 comments on commit 793895c

Please sign in to comment.
Something went wrong with that request. Please try again.