Dripline-Cpp  v2.4.2
Dripline Implementation in C++
relayer.hh
Go to the documentation of this file.
1 #ifndef DRIPLINE_AMQP_RELAYER_HH_
2 #define DRIPLINE_AMQP_RELAYER_HH_
3 
4 
5 #include "core.hh"
6 #include "receiver.hh"
7 
8 #include "cancelable.hh"
9 #include "concurrent_queue.hh"
10 
11 #include <condition_variable>
12 #include <mutex>
13 
14 namespace scarab
15 {
16  class param_node;
17 }
18 
19 namespace dripline
20 {
21 
37  class DRIPLINE_API relayer : public core, public scarab::cancelable
38  {
39  public:
40  relayer( const scarab::param_node& a_config = scarab::param_node(), const std::string& a_broker_address = "", unsigned a_port = 0, const std::string& a_auth_file = "" );
41  virtual ~relayer();
42 
43  public:
44  //*****************
45  // thread functions
46  //*****************
47 
49  void execute_relayer();
50 
51  public:
52  //********************************
53  // asynchronous message submission
54  //********************************
55 
62  {
63  mutable std::mutex f_mutex;
64  mutable std::condition_variable f_condition_var;
66  };
67  typedef std::shared_ptr< wait_for_send_pkg > wait_for_send_pkg_ptr;
68 
71  wait_for_send_pkg_ptr send_async( request_ptr_t a_request ) const;
74  wait_for_send_pkg_ptr send_async( alert_ptr_t a_alert ) const;
75 
83  reply_ptr_t wait_for_reply( const wait_for_send_pkg_ptr a_receive_reply, int a_timeout_ms = 0 );
92  reply_ptr_t wait_for_reply( const wait_for_send_pkg_ptr a_receive_reply, bool& a_chan_valid, int a_timeout_ms = 0 );
93 
94  private:
95  void do_cancellation( int a_code );
96 
98  {
100  wait_for_send_pkg_ptr f_wait_for_send_pkg;
101  };
102  typedef std::shared_ptr< message_and_reply > mar_ptr;
103 
104  mutable scarab::concurrent_queue< mar_ptr > f_queue;
105 
106  mv_referrable( receiver, msg_receiver );
107 
108  };
109 
110 }
111 
112 #endif
scarab::concurrent_queue< mar_ptr > f_queue
Definition: relayer.hh:104
Extended sent-message package that adds thread synchronization objects.
Definition: relayer.hh:61
std::shared_ptr< message_and_reply > mar_ptr
Definition: relayer.hh:102
std::shared_ptr< sent_msg_pkg > sent_msg_pkg_ptr
Definition: dripline_fwd.hh:27
std::shared_ptr< msg_request > request_ptr_t
Definition: dripline_fwd.hh:23
std::shared_ptr< msg_alert > alert_ptr_t
Definition: dripline_fwd.hh:25
wait_for_send_pkg_ptr f_wait_for_send_pkg
Definition: relayer.hh:100
std::condition_variable f_condition_var
Definition: relayer.hh:64
Definition: core.hh:17
#define DRIPLINE_API
Definition: dripline_api.hh:34
Asynchronous message sending.
Definition: relayer.hh:37
A receiver is able to collect Dripline message chunks and reassemble them into a complete Dripline me...
Definition: receiver.hh:76
std::shared_ptr< msg_reply > reply_ptr_t
Definition: dripline_fwd.hh:24
sent_msg_pkg_ptr f_sent_msg_pkg_ptr
Definition: relayer.hh:65
std::shared_ptr< wait_for_send_pkg > wait_for_send_pkg_ptr
Definition: relayer.hh:67
Basic AMQP interactions, including sending messages and interacting with AMQP channels.
Definition: core.hh:72
std::shared_ptr< message > message_ptr_t
Definition: dripline_fwd.hh:20