2 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/app/netmap/SendTransportEngine.hpp" 6 namespace hmbdc {
namespace app {
namespace netmap {
12 using ptr = std::shared_ptr<Sender>;
15 friend struct NetContext;
16 Sender(SendTransportEngine::ptr transport, comm::Topic
const& t)
17 : transport_(transport)
33 template <
typename Message,
typename T
34 ,
typename Enabled =
typename std::enable_if<std::is_integral<T>::value,
void>::type>
35 void send(Message&& msg, T len) {
36 using raw =
typename std::decay<Message>::type;
37 static_assert(std::is_trivially_destructible<raw>::value,
"cannot send message with dtor");
38 transport_->queueBytes(
39 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
51 template <
typename... Messages>
52 void send(Messages&&... msgs) {
53 transport_->queue(topic_, std::forward<Messages>(msgs)...);
64 template <
typename... Messages>
65 bool trySend(Messages&&... msgs) {
66 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
77 template <
typename Message,
typename ... Args>
78 void sendInPlace(Args&&... args) {
79 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
92 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
93 transport_->queueBytes(topic_, tag, bytes, len);
96 SendTransportEngine::ptr transport_;