1 #include "hmbdc/Copyright.hpp" 3 #include "hmbdc/app/tcpcast/SendTransportEngine.hpp" 4 #include "hmbdc/app/RequestReply.hpp" 5 #include "hmbdc/MetaUtils.hpp" 7 namespace hmbdc {
namespace app {
namespace tcpcast {
14 using ptr = std::shared_ptr<Sender>;
18 : transport_(transport)
35 template <
typename Message,
typename T
36 ,
typename Enabled =
typename std::enable_if<std::is_integral<T>::value,
void>::type>
37 void send(Message&& msg, T len) {
39 using raw =
typename decay<Message>::type;
40 static_assert(std::is_trivially_destructible<raw>::value,
"cannot send message with dtor");
41 static_assert(!is_base_of<hasMemoryAttachment, raw>::value
43 ,
"hasMemoryAttachment has to the first base for Message");
44 transport_->queueBytes(
45 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
57 template <
typename... Messages>
58 void send(Messages&&... msgs) {
59 transport_->queue(topic_, std::forward<Messages>(msgs)...);
71 template <
typename... Messages>
73 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
84 template <
typename Message,
typename ... Args>
86 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
99 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
100 transport_->queueBytes(topic_, tag, bytes, len);
103 SendTransport::ptr transport_;
fascade class for sending network messages
Definition: Sender.hpp:12
void sendInPlace(Args &&... args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:85
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: TypedString.hpp:76
synchronous request reply interface for the Network Sender
Definition: RequestReply.hpp:166
void send(Messages &&... msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:58
Definition: MetaUtils.hpp:36
a singleton that holding tcpcast resources
Definition: NetContext.hpp:44
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:99
void send(Message &&msg, T len)
send a message's first bytes
Definition: Sender.hpp:37
bool trySend(Messages &&... msgs)
try to send a batch of message asynchronizely
Definition: Sender.hpp:72