1 #include "hmbdc/Copyright.hpp"
3 #include "hmbdc/app/netmap/SendTransportEngine.hpp"
4 #include "hmbdc/app/RequestReply.hpp"
6 namespace hmbdc {
namespace app {
namespace netmap {
13 using ptr = std::shared_ptr<Sender>;
18 : transport_(transport)
34 template <
typename Message,
typename T
35 ,
typename Enabled =
typename std::enable_if<std::is_integral<T>::value,
void>::type>
36 void send(Message&& msg, T len) {
37 using raw =
typename std::decay<Message>::type;
38 static_assert(std::is_trivially_destructible<raw>::value,
"cannot send message with dtor");
39 transport_->queueBytes(
40 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
52 template <
typename... Messages>
53 void send(Messages&&... msgs) {
54 transport_->queue(topic_, std::forward<Messages>(msgs)...);
65 template <
typename... Messages>
67 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
78 template <
typename Message,
typename ... Args>
80 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
93 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
94 transport_->queueBytes(topic_, tag, bytes, len);
97 SendTransportEngine::ptr transport_;
void sendInPlace(Args &&...args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:79
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
fascade class for sending network messages
Definition: Sender.hpp:11
synchronous request reply interface for the Network Sender
Definition: RequestReply.hpp:166
bool trySend(Messages &&...msgs)
try to send a batch of message asynchronizely, return false if queue is full
Definition: Sender.hpp:66
void send(Messages &&...msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:53
void send(Message &&msg, T len)
send a message's first bytes
Definition: Sender.hpp:36
void sendBytes(uint16_t tag, void const *bytes, size_t len)
send a message asynchronizely by providing message in tag and bytes
Definition: Sender.hpp:93
a singleton that holding netmap resources
Definition: NetContext.hpp:38