hmbdc
simplify-high-performance-messaging-programming
NetContextUtil.hpp
1 #include "hmbdc/app/Base.hpp"
2 
3 #include <utility>
4 
5 namespace hmbdc { namespace app { namespace utils {
6 
7 struct NetContextUtil {
8 protected:
9  template <typename CcNetContext, typename CcContext>
10  static
11  typename std::enable_if<CcContext::cpa::has_pool, void>::type
12  createMinimumNetContext(CcNetContext& netCtx
13  , Context<>& runnerCtx
14  , CcContext& ctx
15  , Config::Base const* cfgIn
16  , char const* sendSec
17  , char const* recvSec
18  , size_t maxMessageSize
19  , uint8_t runningUsingThreadIndex
20  , char const* listenToTopic) {
21 
22  runnerCtx.start(1, 1u << runningUsingThreadIndex);
23  if (sendSec == nullptr || sendSec[0]) {
24  auto eng = netCtx.createSendTransportEngine(
25  Config(*cfgIn, sendSec)
26  , maxMessageSize?maxMessageSize:ctx.maxMessageSize()
27  );
28  runnerCtx.addToPool(*eng);
29  }
30  if (recvSec == nullptr || recvSec[0]) {
31  auto eng = netCtx.createRecvTransportEngine(
32  Config(*cfgIn, recvSec)
33  , ctx.buffer()
34  );
35  runnerCtx.addToPool(*eng);
36  netCtx.listenTo(Topic(listenToTopic));
37  }
38  }
39 };
40 }}}
class to hold an hmbdc configuration
Definition: Config.hpp:44
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: NetContextUtil.hpp:7
void start(uint16_t poolThreadCount, uint64_t poolThreadsCpuAffinityMask, Args &&...args)
start the context and specify its Pool and direct Clients
Definition: Context.hpp:585
void addToPool(Client &client, uint64_t poolThreadAffinityIn=0xfffffffffffffffful)
add a client to Context&#39;s pool - the Client is run in pool mode
Definition: Context.hpp:501
A Context is like a media object that facilitates the communications for the Clients that it is holdi...
Definition: Context.hpp:408
Definition: Base.hpp:12