hmbdc
simplify-high-performance-messaging-programming
Transport.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 
4 #include "hmbdc/app/Config.hpp"
5 #include "hmbdc/text/StringTrieSet.hpp"
6 #include "hmbdc/comm/Topic.hpp"
7 #include "hmbdc/comm/inet/Misc.hpp"
8 #include "hmbdc/time/Timers.hpp"
9 #include "hmbdc/pattern/MonoLockFreeBuffer.hpp"
10 #include "hmbdc/Compile.hpp"
11 
12 #include <boost/regex.hpp>
13 #include <boost/asio.hpp>
14 
15 #include <memory>
16 
17 extern thread_local std::shared_ptr<boost::asio::io_service> gtIos;
18 
19 namespace hmbdc { namespace app { namespace tcpcast {
20 
21 using namespace hmbdc;
22 using namespace hmbdc::time;
23 using namespace boost::asio;
24 
25 extern thread_local std::shared_ptr<boost::asio::io_service> gtIos;
26 
27 struct Transport {
28  using ptr = std::shared_ptr<Transport>;
29 
30  Transport(Config const& cfg)
31  : config_(cfg)
32  , pIos_(nullptr)
33  , tcpcastAdTopic_("tcpcastad") {
34  cfg (hmbdcName_, "hmbdcName")
35  (schedPolicy_, "schedPolicy")
36  (schedPriority_, "schedPriority")
37  ;
38  }
39 
40  void initInThread() {
41  if (!::gtIos) {
42  ::gtIos.reset(new io_service(1u));
43  }
44  pIos_ = ::gtIos;
45  }
46 
47  bool operator == (Transport const& other ) const {
48  return &config_ == &other.config_;
49  }
50 
51  bool operator < (Transport const& other ) const {
52  return &config_ < &other.config_;
53  }
54 
55  virtual ~Transport(){}
56 
57 protected:
58  Config const config_;
59  string hmbdcName_;
60  string schedPolicy_;
61  int schedPriority_;
62  ip::udp::endpoint endpoint_;
63  std::shared_ptr<io_service> pIos_;
64  Topic const tcpcastAdTopic_;
65 };
66 }}}
class to hold an hmbdc configuration
Definition: Config.hpp:35
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: Transport.hpp:27
Definition: Rater.hpp:10
Definition: Client.hpp:11