ZIO
Python and C++ interface to ZeroMQ and Zyre
flow.hpp
Go to the documentation of this file.
1 
5 #ifndef ZIO_FLOW_HPP_SEEN
6 #define ZIO_FLOW_HPP_SEEN
7 
8 #include "zio/port.hpp"
9 #include "zio/message.hpp"
10 
11 namespace zio {
12 
13 
17  namespace flow {
19 
20 
21  class Flow {
22  public:
26  Flow(portptr_t port);
27  ~Flow();
28 
34  void send_bot(Message& bot);
35 
44  bool recv_bot(Message& bot, int timeout=-1);
45 
51  bool put(Message& dat);
52 
62  int slurp_pay(int timeout);
63 
72  bool get(Message& dat, int timeout=-1);
73 
81  int flush_pay();
82 
92  void send_eot(Message& msg);
93 
94 
106  bool recv_eot(Message& msg, int timeout=-1);
107 
108  bool is_sender() const { return m_sender; }
109  int credit() const { return m_credit; }
110  int total_credit() const { return m_total_credit; }
111  private:
112  portptr_t m_port;
113  int m_credit, m_total_credit;
114  bool m_sender; // false if we are recver
115 
116  // A Flow can use a SERVER socket. The BOT in recv() sets
117  // this. It will be set on the message prior to any
118  // subsequent send()
119  Message::routing_id_t m_rid;
120 
121  int m_send_seqno{-1};
122  int m_recv_seqno{-1};
123 
124  bool parse_label(Message& msg, zio::json& lobj);
125  };
126 
127  }
128 }
129 
130 #endif
131 
bool recv_eot(Message &msg, int timeout=-1)
Receive an EOT.
Definition: flow.cpp:252
Flow(portptr_t port)
create a flow.
Definition: flow.cpp:4
void send_eot(Message &msg)
send EOT.
Definition: flow.cpp:238
bool is_sender() const
Definition: flow.hpp:108
bool put(Message &dat)
put a payload message into the flow
Definition: flow.cpp:153
int credit() const
Definition: flow.hpp:109
std::shared_ptr< Port > portptr_t
The context can&#39;t be copied and ports like to be shared.
Definition: port.hpp:148
bool recv_bot(Message &bot, int timeout=-1)
receive a BOT
Definition: flow.cpp:59
int total_credit() const
Definition: flow.hpp:110
uint32_t routing_id_t
Definition: message.hpp:62
int slurp_pay(int timeout)
recv any waiting PAY messages
Definition: flow.cpp:118
Direction
Definition: flow.hpp:18
void send_bot(Message &bot)
send a BOT
Definition: flow.cpp:39
a ZIO message
Definition: message.hpp:59
implementation of ZIO data flow protocol endpoints
Definition: actor.hpp:14
int flush_pay()
send any accumulated credit as a PAY
Definition: flow.cpp:193
nlohmann::json json
Definition: interned.hpp:9