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

State flow implementing select-aware fd reads. More...

#include <HubDeviceSelect.hxx>

Inheritance diagram for HubDeviceSelectReadFlow< HFlow >:
StateFlowBase Executable Notifiable QMember Destructable

Public Types

typedef HFlow::buffer_type buffer_type
 Buffer type.
 

Public Member Functions

 HubDeviceSelectReadFlow (FdHubPortService *device, typename HFlow::port_type *dst, typename HFlow::port_type *skip_member)
 Constructor.
 
void set_limit_input (bool should_throttle)
 
void shutdown ()
 Unregisters the current flow from the hub.
 
FdHubPortServicedevice ()
 
Action allocate_buffer ()
 Allocates a new buffer for incoming data.
 
Action try_read ()
 Attempts to read into the current buffer from the target fd.
 
Action read_done ()
 Called when the stateflow read call(s) are completed.
 
- Public Member Functions inherited from StateFlowBase
void run () override
 Callback from the executor.
 
void notify () override
 Wakeup call arrived.
 
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.
 

Private Member Functions

void notify_barrier ()
 Calls into the parent flow's barrier notify, but makes sure to only do this once in the lifetime of *this.
 

Private Attributes

bool barrierOwned_ {true}
 true iff pending parent->barrier_.notify()
 
bool shouldThrottle_
 True if we are throttling via a limited pool.
 
StateFlowSelectHelper selectHelper_ {this}
 Helper object for read/write FD asynchronously.
 
buffer_typeb_
 Buffer that we are currently filling.
 
std::unique_ptr< LimitedPoolinputPool_
 Throttling input helper.
 
HFlow::port_type * dst_
 Where do we forward the messages we created.
 
HFlow::port_type * skipMember_
 What should be the source port designation.
 

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.
 
- Protected Types inherited from StateFlowBase
typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 
- 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 Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

template<class HFlow>
class HubDeviceSelectReadFlow< HFlow >

State flow implementing select-aware fd reads.

Definition at line 159 of file HubDeviceSelect.hxx.

Member Typedef Documentation

◆ buffer_type

template<class HFlow >
typedef HFlow::buffer_type HubDeviceSelectReadFlow< HFlow >::buffer_type

Buffer type.

Definition at line 163 of file HubDeviceSelect.hxx.

Constructor & Destructor Documentation

◆ HubDeviceSelectReadFlow()

template<class HFlow >
HubDeviceSelectReadFlow< HFlow >::HubDeviceSelectReadFlow ( FdHubPortService device,
typename HFlow::port_type *  dst,
typename HFlow::port_type *  skip_member 
)
inline

Constructor.

Parameters
deviceparent object.

Definition at line 168 of file HubDeviceSelect.hxx.

Member Function Documentation

◆ allocate_buffer()

template<class HFlow >
Action HubDeviceSelectReadFlow< HFlow >::allocate_buffer ( )
inline

Allocates a new buffer for incoming data.

Returns
next state.

Definition at line 210 of file HubDeviceSelect.hxx.

◆ device()

template<class HFlow >
FdHubPortService * HubDeviceSelectReadFlow< HFlow >::device ( )
inline
Returns
the parent object.

Definition at line 204 of file HubDeviceSelect.hxx.

◆ notify_barrier()

template<class HFlow >
void HubDeviceSelectReadFlow< HFlow >::notify_barrier ( )
inlineprivate

Calls into the parent flow's barrier notify, but makes sure to only do this once in the lifetime of *this.

Definition at line 261 of file HubDeviceSelect.hxx.

◆ read_done()

template<class HFlow >
Action HubDeviceSelectReadFlow< HFlow >::read_done ( )
inline

Called when the stateflow read call(s) are completed.

Returns
next state.

Error reading the socket.

Definition at line 240 of file HubDeviceSelect.hxx.

◆ set_limit_input()

template<class HFlow >
void HubDeviceSelectReadFlow< HFlow >::set_limit_input ( bool  should_throttle)
inline

Definition at line 180 of file HubDeviceSelect.hxx.

◆ shutdown()

template<class HFlow >
void HubDeviceSelectReadFlow< HFlow >::shutdown ( )
inline

Unregisters the current flow from the hub.

Must be called on the main executor.

Definition at line 192 of file HubDeviceSelect.hxx.

◆ try_read()

template<class HFlow >
Action HubDeviceSelectReadFlow< HFlow >::try_read ( )
inline

Attempts to read into the current buffer from the target fd.

Returns
next state.

Definition at line 219 of file HubDeviceSelect.hxx.

Member Data Documentation

◆ b_

template<class HFlow >
buffer_type* HubDeviceSelectReadFlow< HFlow >::b_
private

Buffer that we are currently filling.

Definition at line 277 of file HubDeviceSelect.hxx.

◆ barrierOwned_

template<class HFlow >
bool HubDeviceSelectReadFlow< HFlow >::barrierOwned_ {true}
private

true iff pending parent->barrier_.notify()

Definition at line 271 of file HubDeviceSelect.hxx.

◆ dst_

template<class HFlow >
HFlow::port_type* HubDeviceSelectReadFlow< HFlow >::dst_
private

Where do we forward the messages we created.

Definition at line 281 of file HubDeviceSelect.hxx.

◆ inputPool_

template<class HFlow >
std::unique_ptr<LimitedPool> HubDeviceSelectReadFlow< HFlow >::inputPool_
private

Throttling input helper.

Definition at line 279 of file HubDeviceSelect.hxx.

◆ selectHelper_

template<class HFlow >
StateFlowSelectHelper HubDeviceSelectReadFlow< HFlow >::selectHelper_ {this}
private

Helper object for read/write FD asynchronously.

Definition at line 275 of file HubDeviceSelect.hxx.

◆ shouldThrottle_

template<class HFlow >
bool HubDeviceSelectReadFlow< HFlow >::shouldThrottle_
private

True if we are throttling via a limited pool.

Definition at line 273 of file HubDeviceSelect.hxx.

◆ skipMember_

template<class HFlow >
HFlow::port_type* HubDeviceSelectReadFlow< HFlow >::skipMember_
private

What should be the source port designation.

Definition at line 283 of file HubDeviceSelect.hxx.


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