hmbdc
simplify-high-performance-messaging-programming
|
a singleton that holding tcpcast resources More...
#include <NetContext.hpp>
Public Member Functions | |
SendTransportEngine * | createSendTransportEngine (Config const &cfgIn, size_t maxMessageSize) |
construct a send transport enngine (and remember it) More... | |
SendTransportEngine * | createSendTransportEngineTuply (Config const &cfg, size_t maxMessageSize, std::tuple< size_t > args) |
same as above but provide an unified interface - not preferred More... | |
template<typename Buffer , typename MsgArbitrator = RecvTransport::NoOpArb> | |
auto | createRecvTransportEngine (Config const &cfgIn, Buffer &buffer, MsgArbitrator &&arb=RecvTransport::NoOpArb()) |
construct a recv transport and remember it More... | |
template<typename Buffer , typename ArgsTuple > | |
auto | createRecvTransportEngineTuply (Config const &cfg, Buffer &buffer, ArgsTuple &&args) |
same as above but to provide a unified interface - not preferred More... | |
Sender * | getSender (comm::Topic const &t) |
get (or create for the first time) a Sender - whose function is to send messages on its associated Topic More... | |
void | listenTo (comm::Topic const &t) |
This process is interested in a Topic. More... | |
void | stopListenTo (comm::Topic const &t) |
undo the subscription More... | |
Private Member Functions | |
template<typename CcContext > | |
NetContext (CcContext &ctx, Config::Base cfgIn=Config::Base{}, char const *sendSec=nullptr, char const *recvSec=nullptr, size_t maxMessageSize=0, uint8_t runningUsingThreadIndex=0, char const *listenToTopic="_") | |
this ctor is to create some commonly used basic engine setup to start with. This is private and only meant to be used through SingletonGuardian, see in example chat.cpp Config config; //other config values are default config.put("ifaceAddr", ifaceAddr);//which interface to use for communication config.put("loopback", true); //could be chatting on the same machine Context<sizeof(ChatMessage)> ctx; //large enough to hold ChatMessage's //create NetContext with initial tx/rx capabilities, and listen to the default topic "_" //received network messages goes to ctx. this launches a thread to power the above engines SingletonGuardian<tcpcast::NetContext> g(ctx, config); //RAII for tcpcast::NetContext resources | |
NetContext () | |
this is for users that want finer control of engine creation - from a blank NetContext. More... | |
Friends | |
struct | hmbdc::pattern::SingletonGuardian< NetContext > |
a singleton that holding tcpcast resources
it manages transport engines
see perf-tcpcast.cpp chat.cpp for usage.
|
inlineprivate |
this ctor is to create some commonly used basic engine setup to start with. This is private and only meant to be used through SingletonGuardian, see in example chat.cpp
It creates one send transport engine and/or one recv transport engine based on cfgIn. and run them using a single OS thread indicated by runningUsingThreadIndex If recv engine is created, this method also automaticallly makes the NetContext listen to a default topic (listenToTopic).
ctx | a Context that manages the send / recv transport engines, and hold the received messages |
cfgIn | optional Config for the send AND recv transport engines |
sendSec | the section name for send transport engine in above cfgIn, special values: nullptr - create send engine using no section config values "" - do not create send engine |
recvSec | the section name for recv transport engine in above cfgIn nullptr - create recv engine using no section config values "" - do not create recv engine |
maxMessageSize | max message size in bytes to be sent, if 0, uses ctx's maxMessageSize() |
runningUsingThreadIndex | see details above |
CcContext | ctx Context type |
|
inlineprivate |
this is for users that want finer control of engine creation - from a blank NetContext.
it does not do anything that the previous ctor does
|
inline |
construct a recv transport and remember it
After this, user is respoonsible to get it started within a hmbdc Context, or rotated continously.
cfgIn | jason specifing the transport - see perf-tcpcast.cpp and hmbdc/app/tcpcast/DefaultUserConfig.hpp |
buffer | buffer that recv messages go, normally the one returned by app::Context::buffer() |
arb | optonally an arbitrator to decide which messages to keep and drop if arb is an rvalue, it is passed in value, if an lvalue, passed in as reference; it supports ONLY hmbdc message level (AFTER topic filtering) arbitration if int operator()(TransportMessageHeader const* header) presents in the arb passed in. (NO packet level since it is tcp) |
|
inline |
same as above but to provide a unified interface - not preferred
use forward_as_tuple to make the tuple passed in
|
inline |
construct a send transport enngine (and remember it)
After this, user is responsible to get it started within a hmbdc Context, or rotated continously. Don't create the same thing twice.
cfgIn | jason specifing the transport - see perf-tcpcast.cpp and hmbdc/app/tcpcast/DefaultUserConfig.hpp |
maxMessageSize | max messafe size in bytes to be sent hold the message in buffer |
|
inline |
same as above but provide an unified interface - not preferred
|
inline |
|
inline |
This process is interested in a Topic.
Normally the receiving transport covering this topic needs to be created - not necessarily running - before calling this
t | Topic interested |
|
inline |
undo the subscription
t | Topic |