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