Dripline-Cpp  v2.10.11
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, const scarab::authentication& a_auth );
41  relayer( const relayer& ) = delete;
42  relayer( relayer&& ) = default;
43  virtual ~relayer() = default;
44 
45  relayer& operator=( const relayer& ) = delete;
46  relayer& operator=( relayer&& );
47 
48  public:
49  //*****************
50  // thread functions
51  //*****************
52 
54  void execute_relayer();
55 
56  public:
57  //********************************
58  // asynchronous message submission
59  //********************************
60 
67  {
68  mutable std::mutex f_mutex;
69  mutable std::condition_variable f_condition_var;
71  };
72  typedef std::shared_ptr< wait_for_send_pkg > wait_for_send_pkg_ptr;
73 
76  wait_for_send_pkg_ptr send_async( request_ptr_t a_request ) const;
79  wait_for_send_pkg_ptr send_async( alert_ptr_t a_alert ) const;
80 
88  reply_ptr_t wait_for_reply( const wait_for_send_pkg_ptr a_receive_reply, int a_timeout_ms = 0 );
97  reply_ptr_t wait_for_reply( const wait_for_send_pkg_ptr a_receive_reply, core::post_listen_status& a_status, int a_timeout_ms = 0 );
98 
99  private:
100  void do_cancellation( int a_code );
101 
103  {
106  };
107  typedef std::shared_ptr< message_and_reply > mar_ptr;
108 
109  mutable scarab::concurrent_queue< mar_ptr > f_queue;
110 
111  mv_referrable( receiver, msg_receiver );
112 
113  };
114 
115 }
116 
117 #endif
Basic AMQP interactions, including sending messages and interacting with AMQP channels.
Definition: core.hh:75
post_listen_status
Definition: core.hh:80
A receiver is able to collect Dripline message chunks and reassemble them into a complete Dripline me...
Definition: receiver.hh:78
Asynchronous message sending.
Definition: relayer.hh:38
virtual ~relayer()=default
std::shared_ptr< message_and_reply > mar_ptr
Definition: relayer.hh:107
relayer & operator=(const relayer &)=delete
std::shared_ptr< wait_for_send_pkg > wait_for_send_pkg_ptr
Definition: relayer.hh:72
relayer(relayer &&)=default
scarab::concurrent_queue< mar_ptr > f_queue
Definition: relayer.hh:109
relayer(const relayer &)=delete
#define DRIPLINE_API
Definition: dripline_api.hh:34
std::shared_ptr< msg_alert > alert_ptr_t
Definition: dripline_fwd.hh:25
std::shared_ptr< message > message_ptr_t
Definition: dripline_fwd.hh:20
std::shared_ptr< sent_msg_pkg > sent_msg_pkg_ptr
Definition: dripline_fwd.hh:27
std::shared_ptr< msg_reply > reply_ptr_t
Definition: dripline_fwd.hh:24
std::shared_ptr< msg_request > request_ptr_t
Definition: dripline_fwd.hh:23
Definition: agent.hh:18
wait_for_send_pkg_ptr f_wait_for_send_pkg
Definition: relayer.hh:105
Extended sent-message package that adds thread synchronization objects.
Definition: relayer.hh:67
sent_msg_pkg_ptr f_sent_msg_pkg_ptr
Definition: relayer.hh:70
std::condition_variable f_condition_var
Definition: relayer.hh:69