1 #include "hmbdc/Copyright.hpp" 3 #include "hmbdc/app/netmap/SendTransportEngine.hpp" 5 namespace hmbdc {
namespace app {
namespace netmap {
11 using ptr = std::shared_ptr<Sender>;
16 : transport_(transport)
32 template <
typename Message,
typename T
33 ,
typename = std::enable_if<std::is_integral<T>::value>>
34 void send(Message&& msg, T len) {
35 using raw =
typename std::remove_reference<Message>::type;
36 static_assert(std::is_trivially_destructible<raw>::value,
"cannot send message with dtor");
37 transport_->queueBytes(
38 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
50 template <
typename... Messages>
51 void send(Messages&&... msgs) {
52 transport_->queue(topic_, std::forward<Messages>(msgs)...);
63 template <
typename... Messages>
65 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
76 template <
typename Message,
typename ... Args>
78 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
91 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
92 transport_->queueBytes(topic_, tag, bytes, len);
95 SendTransportEngine::ptr transport_;
bool trySend(Messages &&... msgs)
try to send a batch of message asynchronizely, return false if queue is full
Definition: Sender.hpp:64
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
void send(Messages &&... msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:51
fascade class for sending network messages
Definition: Sender.hpp:10
void sendInPlace(Args &&... args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:77
void send(Message &&msg, T len)
send a message's first bytes
Definition: Sender.hpp:34
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:91
a singleton that holding netmap resources
Definition: NetContext.hpp:38