Time Event class. More...
#include "qp.h"
Public Member Functions | |
void | QTimeEvt_ctorX (QTimeEvt *const me, QActive *const act, enum_t const sig, uint_fast8_t const tickRate) |
void | QTimeEvt_armX (QTimeEvt *const me, uint32_t const nTicks, uint32_t const interval) |
bool | QTimeEvt_disarm (QTimeEvt *const me) |
bool | QTimeEvt_rearm (QTimeEvt *const me, uint32_t const nTicks) |
bool | QTimeEvt_wasDisarmed (QTimeEvt *const me) |
QTimeEvtCtr | QTimeEvt_currCtr (QTimeEvt const *const me) |
Static Public Member Functions | |
bool | QTimeEvt_noActive (uint_fast8_t const tickRate) |
Static Public Member Functions inherited from QEvt | |
static void | QEvt_ctor (QEvt *const me, enum_t const sig) |
static QEvt * | QEvt_init (QEvt *const me, uint8_t const dummy) |
Protected Attributes | |
QEvt | super |
Private Member Functions | |
QTimeEvt * | QTimeEvt_expire_ (QTimeEvt *const me, QTimeEvt *const prev_link, QActive const *const act, uint_fast8_t const tickRate) |
Static Private Member Functions | |
void | QTimeEvt_init (void) |
void | QTimeEvt_tick_ (uint_fast8_t const tickRate, void const *const sender) |
void | QTimeEvt_tick1_ (uint_fast8_t const tickRate, void const *const sender) |
Private Attributes | |
struct QTimeEvt *volatile | next |
Link to the next time event in the list. | |
void * | act |
Active object that receives the time events. | |
QTimeEvtCtr volatile | ctr |
Down-counter of the time event. | |
QTimeEvtCtr | interval |
Interval for periodic time event (zero for one-shot time event) | |
uint8_t | tickRate |
uint8_t | flags |
QTimeEvt | QTimeEvt_timeEvtHead_ [QF_MAX_TICK_RATE] |
Array of heads of linked lists of time events (one for every clock tick rate) | |
Additional Inherited Members | |
Public Attributes inherited from QEvt | |
QSignal | sig |
Signal of the event (see Event Signal) | |
Time Event class.
Time events are special QF events equipped with the notion of time passage. The basic usage model of the time events is as follows. An active object allocates one or more QTimeEvt objects (provides the storage for them). When the active object needs to arrange for a timeout, it arms one of its time events to fire either just once (one-shot) or periodically. Each time event times out independently from the others, so a QF application can make multiple parallel timeout requests (from the same or different active objects). When QF detects that the appropriate moment has arrived, it inserts the time event directly into the recipient's event queue. The recipient then processes the time event just like any other event.
Time events, as any other QF events derive from the QEvt base class. Typically, you will use a time event as-is, but you can also further derive more specialized time events from it by adding some more data members and/or specialized functions that operate on the specialized time events.
Internally, the armed time events are organized into linked lists–one list for every supported ticking rate. These linked lists are scanned in every invocation of the QTIMEEVT_TICK_X() macro. Only armed (timing out) time events are in the list, so only armed time events consume CPU cycles.
void QTimeEvt_ctorX | ( | QTimeEvt *const | me, |
QActive *const | act, | ||
enum_t const | sig, | ||
uint_fast8_t const | tickRate ) |
void QTimeEvt_armX | ( | QTimeEvt *const | me, |
uint32_t const | nTicks, | ||
uint32_t const | interval ) |
bool QTimeEvt_rearm | ( | QTimeEvt *const | me, |
uint32_t const | nTicks ) |
QTimeEvtCtr QTimeEvt_currCtr | ( | QTimeEvt const *const | me | ) |
|
staticprivate |
|
staticprivate |
|
static |
|
private |
|
private |
Down-counter of the time event.
The down-counter is decremented by 1 in every QTimeEvt_tick_() call. The time event fires (gets posted or published) when the down-counter reaches zero.
|
private |
Interval for periodic time event (zero for one-shot time event)
The value of the interval is re-loaded to the internal down-counter when the time event expires, so that the time event keeps timing out periodically.
|
private |