1 #include "hmbdc/Copyright.hpp" 3 #include "hmbdc/app/Config.hpp" 4 #include "hmbdc/app/netmap/Messages.hpp" 5 #include "hmbdc/app/netmap/Sender.hpp" 6 #include "hmbdc/app/netmap/SendTransportEngine.hpp" 7 #include "hmbdc/app/netmap/RecvTransportEngine.hpp" 8 #include "hmbdc/app/netmap/DefaultUserConfig.hpp" 10 #include "hmbdc/comm/Topic.hpp" 11 #include "hmbdc/pattern/GuardedSingleton.hpp" 13 #include <boost/regex.hpp> 24 namespace hmbdc {
namespace app {
namespace netmap {
58 std::lock_guard<std::mutex> tlock(sendTransportEnginesLock_);
60 sendTransportEngines_.push_back(res);
69 ,
size_t maxMessageSize
70 , std::tuple<> args) {
91 template <
typename Buffer,
typename MsgArbitrator = RecvTransport::NoOpArb>
99 std::lock_guard<std::mutex> tlock(recvTransportEnginesLock_);
102 , std::forward<MsgArbitrator>(arb));
103 recvTransportEngines_.emplace_back(res);
111 template <
typename Buffer,
typename ArgsTuple>
115 , ArgsTuple&& args) {
130 std::lock_guard<std::mutex> lock(sendersLock_);
131 auto sender = senders_.find(t);
132 if ( sender != senders_.end()) {
133 return sender->second.get();
135 std::lock_guard<std::mutex> slock(sendTransportEnginesLock_);
137 i < sendTransportEngines_.size();
139 auto st = sendTransportEngines_[i];
141 auto newSender =
new Sender(st, t);
142 senders_[t].reset(newSender);
159 std::lock_guard<std::mutex> tlock(recvTransportEnginesLock_);
160 for (
auto ptr : recvTransportEngines_) {
171 std::lock_guard<std::mutex> tlock(recvTransportEnginesLock_);
172 for (
auto ptr : recvTransportEngines_) {
173 ptr->stopListenTo(t);
185 std::vector<SendTransportEngine::ptr> sendTransportEngines_;
186 std::mutex sendTransportEnginesLock_;
188 std::vector<RecvTransport::ptr> recvTransportEngines_;
189 std::mutex recvTransportEnginesLock_;
191 std::map<comm::Topic, Sender::ptr> senders_;
192 uint32_t sendTransportRotationIndex_;
193 std::mutex sendersLock_;
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
fascade class for sending network messages
Definition: Sender.hpp:10
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
void listenTo(comm::Topic const &t)
This process is interested in a Topic.
Definition: NetContext.hpp:158
SendTransportEngine * createSendTransportEngineTuply(Config const &cfg, size_t maxMessageSize, std::tuple<> args)
same as above but provide an unified interface - not preferred
Definition: NetContext.hpp:68
auto createRecvTransportEngineTuply(Config const &cfg, Buffer &buffer, ArgsTuple &&args)
same as above but to provide a unified interface - not preferred
Definition: NetContext.hpp:112
power a netmap port sending functions
Definition: SendTransportEngine.hpp:43
SendTransportEngine * createSendTransportEngine(Config const &cfgIn, size_t maxMessageSize)
construct a send transport and remember it
Definition: NetContext.hpp:53
impl class,
Definition: RecvTransportEngine.hpp:70
auto createRecvTransportEngine(Config const &cfgIn, Buffer &buffer, MsgArbitrator &&arb=RecvTransport::NoOpArb())
construct a send transport and remember it
Definition: NetContext.hpp:92
char const *const DefaultUserConfig
Definition: DefaultUserConfig.hpp:10
a singleton that holding netmap resources
Definition: NetContext.hpp:37
a take all arbitrator (no arbitration at all)
Definition: RecvTransportEngine.hpp:50
void stopListenTo(comm::Topic const &t)
undo the subscription
Definition: NetContext.hpp:170
Sender * getSender(comm::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:129