1 #include "hmbdc/Copyright.hpp" 3 #include "hmbdc/app/Config.hpp" 4 #include "hmbdc/app/mcast/Messages.hpp" 5 #include "hmbdc/app/mcast/Sender.hpp" 6 #include "hmbdc/app/mcast/SendTransportEngine.hpp" 7 #include "hmbdc/app/mcast/RecvTransportEngine.hpp" 8 #include "hmbdc/app/mcast/DefaultUserConfig.hpp" 9 #include "hmbdc/comm/Topic.hpp" 10 #include "hmbdc/pattern/GuardedSingleton.hpp" 12 #include <boost/regex.hpp> 22 namespace hmbdc {
namespace app {
namespace mcast {
56 ,
size_t maxMessageSize) {
61 std::lock_guard<std::mutex> tlock(sendTransportsLock_);
63 sendTransports_.emplace_back(res);
72 ,
size_t maxMessageSize
73 , std::tuple<> args) {
96 template <
typename Buffer,
typename MsgArbitrator = RecvTransport::NoOpArb>
104 std::lock_guard<std::mutex> tlock(recvTransportsLock_);
107 , std::forward<MsgArbitrator>(arb));
108 recvTransports_.emplace_back(res);
117 template <
typename Buffer,
typename ArgsTuple>
121 , ArgsTuple&& args) {
136 std::lock_guard<std::mutex> lock(sendersLock_);
137 auto sender = senders_.find(t);
138 if ( sender != senders_.end()) {
139 return sender->second.get();
141 std::lock_guard<std::mutex> slock(sendTransportsLock_);
143 i < sendTransports_.size();
145 auto st = sendTransports_[i];
147 auto newSender =
new Sender(st, t);
148 senders_[t].reset(newSender);
165 std::lock_guard<std::mutex> tlock(recvTransportsLock_);
166 for (
auto ptr : recvTransports_) {
177 std::lock_guard<std::mutex> tlock(recvTransportsLock_);
178 for (
auto ptr : recvTransports_) {
179 ptr->stopListenTo(t);
191 std::vector<SendTransport::ptr> sendTransports_;
192 std::mutex sendTransportsLock_;
194 std::vector<RecvTransport::ptr> recvTransports_;
195 std::mutex recvTransportsLock_;
197 std::map<Topic, Sender::ptr> senders_;
198 std::mutex sendersLock_;
auto createRecvTransportEngine(Config const &cfgIn, Buffer &buffer, MsgArbitrator &&arb=RecvTransport::NoOpArb())
construct a send transport and remember it
Definition: NetContext.hpp:97
void setDefaultUserConfig(Config const &c)
internal use
Definition: Config.hpp:136
class to hold an hmbdc configuration
Definition: Config.hpp:43
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
base for the Singleton that works with SingletonGuardian
Definition: GuardedSingleton.hpp:35
RAII representing the lifespan of the underlying Singleton which also ganrantees the singularity of u...
Definition: GuardedSingleton.hpp:20
a take all arbitrator (no arbitration at all)
Definition: RecvTransportEngine.hpp:33
a singleton that holding mcast resources
Definition: NetContext.hpp:37
SendTransportEngine * createSendTransportEngine(Config const &cfgIn, size_t maxMessageSize)
construct a send transport engine (and remember it within the class)
Definition: NetContext.hpp:55
auto createRecvTransportEngineTuply(Config const &cfg, Buffer &buffer, ArgsTuple &&args)
same as above but to provide a unified interface - not preferred
Definition: NetContext.hpp:118
void stopListenTo(Topic const &t)
undo the subscription
Definition: NetContext.hpp:176
char const *const DefaultUserConfig
Definition: DefaultUserConfig.hpp:10
void listenTo(Topic const &t)
This process is interested in a Topic.
Definition: NetContext.hpp:164
SendTransportEngine * createSendTransportEngineTuply(Config const &cfg, size_t maxMessageSize, std::tuple<> args)
same as above but provide a unified interface - not preferred
Definition: NetContext.hpp:71
Definition: SendTransportEngine.hpp:267
impl class
Definition: RecvTransportEngine.hpp:306
fascade class for sending network messages
Definition: Sender.hpp:14
Sender * getSender(Topic const &t)
get (or create for the first time) a Sender - whose function is to send messages on its associated To...
Definition: NetContext.hpp:135