Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
UntypedStateFlow< QueueType > Class Template Reference

State flow base class with queue but generic message type. More...

#include <StateFlow.hxx>

Inheritance diagram for UntypedStateFlow< QueueType >:
StateFlowWithQueue StateFlowBase Atomic LinkedObject< StateFlowWithQueue > Executable Notifiable QMember Destructable TypedStateFlow< MessageType, UntypedStateFlow< QueueType > > StateFlow< MessageType, QueueType > CallableFlow< ProgrammingTrackRequest > CallableFlow< BroadcastTimeServerDateRolloverFinishInput > CallableFlow< BroadcastTimeServerSetInput > CallableFlow< BroadcastTimeServerSyncInput > CallableFlow< BroadcastTimeServerTimeInput > CallableFlow< BulkAliasRequest > CallableFlow< DccAccyProducerInput > CallableFlow< MemoryConfigClientRequest > CallableFlow< SNIPClientRequest > CallableFlow< StreamReceiveRequest > CallableFlow< TractionThrottleInput > FdHubWriteFlow< typename HFlow::value_type > BufferPort DisplayPort ESPWifiClient FdLoggingServer GCAdapter::BinaryToGCMember GCAdapter::GCToBinaryMember HubDeviceSelect< HFlow, ReadFlow >::WriteFlow HubToGcPort MockSend openlcb::BootloaderPort openlcb::DefaultDatagramHandler openlcb::InitializeFlow openlcb::RailcomToOpenLCBDebugProxy openlcb::SimpleInfoFlow traction_modem::TxFlow

Public Member Functions

 UntypedStateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from StateFlowWithQueue
void notify () override
 Wakeup call arrived. Schedules *this on the executor.
 
bool is_waiting ()
 
- Public Member Functions inherited from StateFlowBase
void run () override
 Callback from the executor.
 
Serviceservice ()
 Return a pointer to the service I am bound to.
 
- Public Member Functions inherited from Executable
void test_deletion ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 
- Public Member Functions inherited from LinkedObject< StateFlowWithQueue >
StateFlowWithQueuelink_next ()
 

Protected Types

typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 
- Protected Types inherited from StateFlowBase
typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 

Protected Member Functions

void send (BufferBase *msg, unsigned priority=UINT_MAX)
 Sends a message to the state flow for processing.
 
QMemberqueue_next (unsigned *priority) OVERRIDE
 Takes the front entry in the queue.
 
bool queue_empty () OVERRIDE
 
Action call_immediately (Callback c)
 Imediately call the next state upon return.
 
- Protected Member Functions inherited from StateFlowWithQueue
 StateFlowWithQueue (Service *service)
 Constructor.
 
virtual Action entry ()=0
 Entry into the StateFlow activity.
 
virtual void release ()=0
 Releases the current message buffer back to the pool it came from.
 
Action exit ()
 Terminates the processing of this flow.
 
Action release_and_exit ()
 Terminates the processing of the current message.
 
BufferBasemessage ()
 
BufferBasetransfer_message ()
 Releases ownership of the current message.
 
void reset_message (BufferBase *message, unsigned priority)
 Sets the current message being processed.
 
unsigned priority ()
 
void set_priority (unsigned priority)
 Overrides the current priority.
 
void start_flow_at_init (Callback c)
 Call this from the constructor of the child class to do some work before the main queue processing loop begins.
 
- Protected Member Functions inherited from StateFlowBase
 StateFlowBase (Service *service)
 Constructor.
 
 ~StateFlowBase ()
 Destructor.
 
void reset_flow (Callback c)
 Resets the flow to the specified state.
 
bool is_state (Callback c)
 
bool is_terminated ()
 
void start_flow (Callback c)
 Resets the flow to the specified state and starts it.
 
Action again ()
 Call the current state again via call_immediately.
 
Action exit ()
 Terminate current StateFlow activity.
 
Action delete_this ()
 Terminates the flow and deletes *this.
 
Action set_terminated ()
 Sets the flow to terminated state.
 
Action call_immediately (Callback c)
 Imediately call the next state upon return.
 
Action wait ()
 Wait for an asynchronous call.
 
Action wait_and_call (Callback c)
 Wait for resource to become available before proceeding to next state.
 
template<class T >
Action allocate_and_call (FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr)
 Allocates a buffer from a pool and proceed to the next state when allocation is successful.
 
Action allocate_and_call (Callback c, QAsync *queue)
 Allocates an entry from an asynchronous queue, and transitions to a state once the allocation is complete.
 
template<class T >
Buffer< T > * full_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
T * full_allocation_result (TypedQAsync< T > *queue)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
void cast_allocation_result (T **member)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
Buffer< T > * get_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation.
 
Action yield_and_call (Callback c)
 Place the current flow to the back of the executor, and transition to a new state after we get the CPU again.
 
Action yield ()
 Place the current flow to the back of the executor, and re-try the current state after we get the CPU again.
 
Action sleep_and_call (::Timer *timer, long long timeout_nsec, Callback c)
 Suspends execution of this control flow for a specified time.
 
template<class T , typename... Args>
Action invoke_subflow_and_wait (FlowInterface< Buffer< T > > *target_flow, Callback c, Args &&... args)
 Calls a helper flow to perform some actions.
 
Action read_repeated (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read and then invokes the next state.
 
Action read_single (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size_t bytes, and blocks the caller until at least one byte is read.
 
Action read_nonblocking (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size bytes, and then invokes the next state, even if only zero bytes are available right now.
 
Action read_repeated_with_timeout (StateFlowTimedSelectHelper *helper, long long timeout_nsec, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read, or a timeout expires.
 
Action internal_try_read ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on reading.
 
Action write_repeated (StateFlowSelectHelper *helper, int fd, const void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Writes some data into a file descriptor, repeating the operation as necessary until all bytes are written.
 
Action internal_try_write ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on writing.
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 
- Protected Member Functions inherited from LinkedObject< StateFlowWithQueue >
StateFlowWithQueuelink_this ()
 
 LinkedObject ()
 Constructor. Puts *this on the linked list.
 
 ~LinkedObject ()
 Constructor. Removes *this from the linked list.
 
StateFlowWithQueuelink_next ()
 

Private Attributes

QueueType queue_
 Implementation of the queue.
 

Additional Inherited Members

- Static Public Member Functions inherited from StateFlowBase
template<class T , typename... Args>
static void invoke_subflow_and_ignore_result (FlowInterface< Buffer< T > > *target_flow, Args &&... args)
 Calls a helper flow to perform some actions.
 
- Static Public Member Functions inherited from LinkedObject< StateFlowWithQueue >
static StateFlowWithQueuelink_head ()
 
static Atomichead_mu ()
 Locks the list for modification (at any entry!).
 
- Static Protected Member Functions inherited from LinkedObject< StateFlowWithQueue >
static StateFlowWithQueuelink_head ()
 
static Atomichead_mu ()
 Locks the list for modification (at any entry!).
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 
- Protected Attributes inherited from LinkedObject< StateFlowWithQueue >
StateFlowWithQueuelink_
 Linked list pointer.
 
- Static Protected Attributes inherited from LinkedObject< StateFlowWithQueue >
static StateFlowWithQueuehead_
 Beginning of the list.
 

Detailed Description

template<class QueueType>
class UntypedStateFlow< QueueType >

State flow base class with queue but generic message type.

This base class contains the function definitions of StateFlow that don't need the actual message type. It's sole purpose is to avoid having to compile these function multiple times for different message type template arguments.

Definition at line 1234 of file StateFlow.hxx.

Member Typedef Documentation

◆ Callback

template<class QueueType >
typedef Action(StateFlowBase::* StateFlowBase::Callback) ()
protected

State Flow callback prototype.

Definition at line 218 of file StateFlow.hxx.

Constructor & Destructor Documentation

◆ UntypedStateFlow()

template<class QueueType >
UntypedStateFlow< QueueType >::UntypedStateFlow ( Service service)
inline

Constructor.

Parameters
servicespecifies which thread to execute this state flow on.

Definition at line 1238 of file StateFlow.hxx.

◆ ~UntypedStateFlow()

template<class QueueType >
UntypedStateFlow< QueueType >::~UntypedStateFlow ( )
inline

Definition at line 1240 of file StateFlow.hxx.

Member Function Documentation

◆ call_immediately()

template<class QueueType >
Action StateFlowBase::call_immediately ( Callback  c)
inlineprotected

Imediately call the next state upon return.

Parameters
cCallback "state" to move to
Returns
function pointer to be returned from state function

Definition at line 318 of file StateFlow.hxx.

◆ queue_empty()

template<class QueueType >
bool UntypedStateFlow< QueueType >::queue_empty ( )
inlineprotectedvirtual
Returns
true if this StateFlow does not have any messages pending in the queue.

Implements StateFlowWithQueue.

Definition at line 1284 of file StateFlow.hxx.

◆ queue_next()

template<class QueueType >
QMember * UntypedStateFlow< QueueType >::queue_next ( unsigned *  priority)
inlineprotectedvirtual

Takes the front entry in the queue.

Returns
NULL if the queue is empty.
Parameters
prioritywill be set to the priority of the queue member removed fomr the queue.

Implements StateFlowWithQueue.

Definition at line 1272 of file StateFlow.hxx.

◆ send()

template<class QueueType >
void UntypedStateFlow< QueueType >::send ( BufferBase msg,
unsigned  priority = UINT_MAX 
)
inlineprotected

Sends a message to the state flow for processing.

This function never blocks.

Parameters
msgMessage to enqueue
prioritythe priority at which to enqueue this message.

Definition at line 1251 of file StateFlow.hxx.

Member Data Documentation

◆ queue_

template<class QueueType >
QueueType UntypedStateFlow< QueueType >::queue_
private

Implementation of the queue.

Definition at line 1291 of file StateFlow.hxx.


The documentation for this class was generated from the following file: