|
Open Model Railroad Network (OpenMRN)
|
State flow that calls a set of Polling objects at a regular interval. More...
#include <RefreshLoop.hxx>
Public Member Functions | |
| template<class Container = std::initializer_list<Polling*>> | |
| RefreshLoop (Node *node, const Container &members) | |
| Constructor. | |
| void | stop () |
| Stops the refresh loop. | |
| void | add_member (Polling *new_member) |
| Adds a new member to the polling loop. | |
| Action | wait_for_tick () |
| State which gets called after the loop is complete. | |
| Action | call_members () |
Public Member Functions inherited from StateFlowBase | |
| void | run () override |
| Callback from the executor. | |
| void | notify () override |
| Wakeup call arrived. | |
| Service * | service () |
| 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 Types | |
| typedef vector< Polling * > | members_type |
| Data structure type for storing the polling members. | |
Private Attributes | |
| WriteHelper | helper_ |
| Message write buffer that is passed to each polling object. | |
| StateFlowTimer | timer_ |
| Helper object for sleeps. | |
| long long | lastTimeout_ |
| Rolling clock of when the next wakeup should happen. | |
| BarrierNotifiable | bn_ |
| Controllable notifier to be passed into the polling objects. | |
| members_type | members_ |
| The actual members. | |
| unsigned | nextMember_ |
| Index for iterating through the members list. | |
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 | |
| QMember * | next |
| pointer to the next member in the queue | |
Private Member Functions inherited from Atomic | |
| void | lock () |
| void | unlock () |
State flow that calls a set of Polling objects at a regular interval.
Usage: Instantiate your objects from descendants of the Polling class. Create a RefreshLoop object and pass in the list of Polling object pointers to the constructor.
Definition at line 62 of file RefreshLoop.hxx.
|
private |
Data structure type for storing the polling members.
Definition at line 149 of file RefreshLoop.hxx.
|
inline |
Constructor.
| node | openlcb Node whose interface/executor we will be using for the polling loop. |
| members | container of Polling* objects (e.g. std::initializer_list<Polling*> or std::vector<Polling*> which need to be polled by this refresh loop. |
Definition at line 73 of file RefreshLoop.hxx.
|
inline |
Adds a new member to the polling loop.
| new_member | the member to be polled. The object ownership is retained by the caller. The object must outlive this RefreshLoop object. |
Definition at line 95 of file RefreshLoop.hxx.
|
inline |
Definition at line 112 of file RefreshLoop.hxx.
|
inline |
Stops the refresh loop.
If you call this funciton, then wait for the executor, then it is safe to delete *this.
Definition at line 84 of file RefreshLoop.hxx.
|
inline |
State which gets called after the loop is complete.
Initializes the next loop and sleeps until it's time to go.
Definition at line 103 of file RefreshLoop.hxx.
|
private |
Controllable notifier to be passed into the polling objects.
Definition at line 147 of file RefreshLoop.hxx.
|
private |
Message write buffer that is passed to each polling object.
Definition at line 141 of file RefreshLoop.hxx.
|
private |
Rolling clock of when the next wakeup should happen.
Definition at line 145 of file RefreshLoop.hxx.
|
private |
The actual members.
Definition at line 151 of file RefreshLoop.hxx.
|
private |
Index for iterating through the members list.
Definition at line 153 of file RefreshLoop.hxx.
|
private |
Helper object for sleeps.
Definition at line 143 of file RefreshLoop.hxx.