|
Open Model Railroad Network (OpenMRN)
|
Basic alarm type that all other alarms are based off of. More...
#include <BroadcastTimeAlarm.hxx>
Classes | |
| class | Wakeup |
Public Member Functions | |
| BroadcastTimeAlarm (Node *node, BroadcastTime *clock, std::function< void(BarrierNotifiable *)> callback) | |
| Constructor. | |
| ~BroadcastTimeAlarm () | |
| Destructor. | |
| void | set_period (time_t period) |
| Start the alarm to expire at the given period from now. | |
| void | set (time_t time) |
| Start the alarm to expire at the given fast time. | |
| void | clear () |
| Inactivate the alarm. | |
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. | |
Protected Member Functions | |
| virtual Action | entry () |
| Entry point to state flow. | |
| virtual void | update_notify () |
| Called by the clock when time, rate, or running state has changed. | |
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 Attributes | |
| BroadcastTime * | clock_ |
| clock that our alarm is based off of | |
Protected Attributes inherited from QMember | |
| QMember * | next |
| pointer to the next member in the queue | |
Private Member Functions | |
| Action | setup () |
| Setup, or wait to setup alarm. | |
| Action | timeout () |
| Wait for timeout or early trigger. | |
| Action | expired () |
| Handle action on timer expiration. | |
| void | wakeup () |
| Wakeup the state machine. Must be called from this service's executor. | |
| DISALLOW_COPY_AND_ASSIGN (BroadcastTimeAlarm) | |
Private Attributes | |
| Wakeup | wakeup_ |
| wakeup helper for scheduling alarms | |
| std::function< void(BarrierNotifiable *)> | callback_ |
| callback for when alarm expires | |
| StateFlowTimer | timer_ |
| timer helper | |
| BarrierNotifiable | bn_ |
| notifiable for callback callee | |
| BarrierNotifiable * | bnPtr_ |
| not null we have an outstanding notification | |
| time_t | expires_ |
| time at which the alarm expires | |
| uint8_t | running_: 1 |
| true if running (alarm armed), else false | |
| uint8_t | set_: 1 |
| true if a start request is pending | |
| BroadcastTime::UpdateSubscribeHandle | updateSubscribeHandle_ |
| handle to the update subscrition used for unsubcribing in the destructor | |
Friends | |
| class | BroadcastTimeAlarm::Wakeup |
| make our wakeup agent a friend | |
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. | |
Basic alarm type that all other alarms are based off of.
Definition at line 44 of file BroadcastTimeAlarm.hxx.
|
inline |
Constructor.
| node | the virtual node that our StateFlowBase service will be derived from |
| clock | clock that our alarm is based off of |
| callback | callback for when alarm expires |
Definition at line 52 of file BroadcastTimeAlarm.hxx.
|
inline |
Destructor.
Definition at line 78 of file BroadcastTimeAlarm.hxx.
|
inline |
Inactivate the alarm.
Definition at line 115 of file BroadcastTimeAlarm.hxx.
|
inlineprotectedvirtual |
Entry point to state flow.
Reimplemented in openlcb::BroadcastTimeAlarmDate, openlcb::BroadcastTimeAlarmMinute, and openlcb::BroadcastTimeServerAlarm.
Definition at line 141 of file BroadcastTimeAlarm.hxx.
|
inlineprivate |
Handle action on timer expiration.
Definition at line 270 of file BroadcastTimeAlarm.hxx.
|
inline |
Start the alarm to expire at the given fast time.
| time | in seconds since epoch to expire |
Definition at line 95 of file BroadcastTimeAlarm.hxx.
|
inline |
Start the alarm to expire at the given period from now.
| period | in fast seconds from now to expire. period is a a signed value. If the fast time rate is negative, the period passed in should also be negative for an expiration in the future. |
Definition at line 88 of file BroadcastTimeAlarm.hxx.
|
inlineprivate |
Setup, or wait to setup alarm.
Definition at line 214 of file BroadcastTimeAlarm.hxx.
|
inlineprivate |
Wait for timeout or early trigger.
Definition at line 254 of file BroadcastTimeAlarm.hxx.
|
inlineprotectedvirtual |
Called by the clock when time, rate, or running state has changed.
Reimplemented in openlcb::BroadcastTimeAlarmDate, openlcb::BroadcastTimeAlarmMinute, and openlcb::BroadcastTimeServerAlarm.
Definition at line 147 of file BroadcastTimeAlarm.hxx.
|
inlineprivate |
Wakeup the state machine. Must be called from this service's executor.
Definition at line 283 of file BroadcastTimeAlarm.hxx.
|
friend |
make our wakeup agent a friend
Definition at line 309 of file BroadcastTimeAlarm.hxx.
|
private |
notifiable for callback callee
Definition at line 297 of file BroadcastTimeAlarm.hxx.
|
private |
not null we have an outstanding notification
Definition at line 298 of file BroadcastTimeAlarm.hxx.
|
private |
callback for when alarm expires
Definition at line 295 of file BroadcastTimeAlarm.hxx.
|
protected |
clock that our alarm is based off of
Definition at line 164 of file BroadcastTimeAlarm.hxx.
|
private |
time at which the alarm expires
Definition at line 299 of file BroadcastTimeAlarm.hxx.
|
private |
true if running (alarm armed), else false
Definition at line 300 of file BroadcastTimeAlarm.hxx.
|
private |
true if a start request is pending
Definition at line 301 of file BroadcastTimeAlarm.hxx.
|
private |
timer helper
Definition at line 296 of file BroadcastTimeAlarm.hxx.
|
private |
handle to the update subscrition used for unsubcribing in the destructor
Definition at line 306 of file BroadcastTimeAlarm.hxx.
|
private |
wakeup helper for scheduling alarms
Definition at line 293 of file BroadcastTimeAlarm.hxx.