hmbdc
simplify-high-performance-messaging-programming
NetContextUtil.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 #include "hmbdc/app/utils/EpollTask.hpp"
4 #include "hmbdc/app/Base.hpp"
5 
6 #include <utility>
7 
8 namespace hmbdc { namespace app { namespace utils {
9 
11 protected:
12  template <typename CcNetContext, typename RunnerContext, typename CcContext>
13  static
14  typename std::enable_if<RunnerContext::cpa::has_pool, void>::type
15  createMinimumNetContext(CcNetContext& netCtx
16  , RunnerContext& runnerCtx
17  , CcContext& ctx
18  , Config::Base const& cfgIn
19  , char const* sendSec
20  , char const* recvSec
21  , size_t maxMessageSize
22  , uint8_t runningUsingThreadIndex
23  , char const* listenToTopic) {
24 
25  runnerCtx.start(1, 1u << runningUsingThreadIndex);
26  if (sendSec == nullptr || sendSec[0]) {
27  auto eng = netCtx.createSendTransportEngine(
28  Config(cfgIn, sendSec)
29  , maxMessageSize?maxMessageSize:ctx.maxMessageSize()
30  );
31  runnerCtx.addToPool(*eng);
32  }
33  if (recvSec == nullptr || recvSec[0]) {
34  auto eng = netCtx.createRecvTransportEngine(
35  Config(cfgIn, recvSec)
36  , ctx.buffer()
37  );
38  runnerCtx.addToPool(*eng);
39  netCtx.listenTo(Topic(listenToTopic));
40  }
41  }
42 
43  void checkEpollTaskInitialization() {
44  auto& pg = utils::gEpollTaskGuard;
45  if (!pg) {
47  }
48  }
49 };
50 }}}
class to hold an hmbdc configuration
Definition: Config.hpp:46
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: NetContextUtil.hpp:10
RAII representing the lifespan of the underlying Singleton which also ganrantees the singularity of u...
Definition: GuardedSingleton.hpp:20
Definition: Base.hpp:13