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>;
15 Sender(SendTransportEngine::ptr transport,
Topic const& t)
16 : transport_(transport)
32 template <
typename Message,
typename T
33 ,
typename = enable_if<is_integral<T>::value>>
34 void send(Message&& msg, T len) {
35 using raw =
typename remove_reference<Message>::type;
36 transport_->queueBytes(
37 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
49 template <
typename... Messages>
50 void send(Messages&&... msgs) {
51 transport_->queue(topic_, std::forward<Messages>(msgs)...);
62 template <
typename... Messages>
64 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
75 template <
typename Message,
typename ... Args>
77 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
90 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
91 transport_->queueBytes(topic_, tag, bytes, len);
94 SendTransportEngine::ptr transport_;
void sendInPlace(Args &&...args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:76
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
fascade class for sending network messages
Definition: Sender.hpp:10
bool trySend(Messages &&...msgs)
try to send a batch of message asynchronizely, return false if queue is full
Definition: Sender.hpp:63
void send(Messages &&...msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:50
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:90
Definition: NetContext.hpp:26
Definition: Client.hpp:11