35#ifndef _OPENLCB_WRITEHELPER_HXX_
36#define _OPENLCB_WRITEHELPER_HXX_
55 typedef string payload_type;
63 : waitForLocalLoopback_(0)
67 const payload_type &last_payload()
72 void clear_last_payload()
77 void set_wait_for_local_loopback(
bool wait =
true)
79 waitForLocalLoopback_ = (wait ? 1 : 0);
132 if (dst_ == global())
136 b->
data()->reset(mti_, node_->node_id(), buffer_);
137 if (waitForLocalLoopback_)
139 b->
data()->set_flag_dst(
143 f->send(b, b->
data()->priority());
149 b->data()->reset(mti_, node_->node_id(), dst_, buffer_);
150 if (waitForLocalLoopback_)
152 b->data()->set_flag_dst(
156 f->send(b, b->data()->priority());
165 unsigned waitForLocalLoopback_ : 1;
169 payload_type buffer_;
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
void notify() override
Implementation of the barrier semantics.
BarrierNotifiable * reset(Notifiable *done)
Resets the barrier. Returns &*this. Asserts that is_done().
void set_done(BarrierNotifiable *done)
Specifies that a given BarrierNotifiable must be called when the Buffer is deallocated (unreffed to z...
Base class for all QMember types that hold data in an expandable format.
T * data()
get a pointer to the start of the data.
An object that can be scheduled on an executor to run.
static MessageType * cast_alloc(QMember *entry)
Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
void alloc_async(Executable *target)
Asynchronously allocates a message buffer from the pool of this flow.
An object that can schedule itself on an executor to run.
Essentially a "next" pointer container.
MessageHandler * global_message_write_flow()
MessageHandler * addressed_message_write_flow()
Base class for NMRAnet nodes conforming to the asynchronous interface.
virtual bool is_initialized()=0
A statically allocated buffer for sending one message to the OpenLCB bus.
void run() override
Entry point.
void WriteAsync(Node *node, Defs::MTI mti, NodeHandle dst, const payload_type &buffer, Notifiable *done)
Originates an NMRAnet message from a particular node.
void alloc_result(QMember *entry) override
Return the result of an alloc_async() from a memory Pool.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
MTI
Known Message type indicators.
@ MTI_INITIALIZATION_COMPLETE
initialization complete
@ WAIT_FOR_LOCAL_LOOPBACK
Specifies that the stack should wait for the local loopback processing before invoking the done notif...
Container of both a NodeID and NodeAlias.