Skip to content
Rich Neswold edited this page Apr 1, 2022 · 2 revisions

Events are used by tasks or interrupt routines to indicate to other tasks that something interesting happened. One or more tasks can wait for an event to occur. The task that signals the event can wake one waiting task, or have all waiting tasks awakened.

NOTE: Starting with v2.7, we introduced a nested, version namespace to enforce matching APIs when building and deploying. In the following code examples, we refer to the namespace as "VWPP". This translates to vwpp for pre-2.7 libraries and to vwpp::v2_7 for v2.7.

The VWPP::Event<> API

This API consists of a templated class, VWPP::Event<>.


Constructor

VWPP::Event<>()

Creates an Event object. If the object can't be created, a std::bad_alloc exception will be thrown.


bool VWPP::Event<VWPP::TaskSignal>::wait(int = WAIT_FOREVER)
bool VWPP::Event<VWPP::IntSignal>::wait(IntLock&, int = WAIT_FOREVER)

A task calling this method will go into a PENDING state until the event gets signaled by another task or interrupt routine. The parameter indicates a timeout, given in milliseconds. No parameter needs to be provided if the default -- wait forever -- is sufficient.

If the wait() timeout expires, the method returns false. If the task is awakened due to the event getting signaled, the method returns true. If this method is called from within an interrupt routine, it always returns false because interrupts cannot block.


void VWPP::Event<>::wakeOne()

Wakes one task pending on the event. If multiple tasks are pending, only the highest priority task runs. If no tasks are pending on the event when this method is called, the first task to wait for the event will not block. If you do not want this behavior, then use wakeAll(). Interrupt routines should only call VWPP::Event<VWPP::IntSignal>::wakeOne().


void VWPP::Event<>::wakeAll()

Wakes all tasks pending on the event. Interrupt routines should only call VWPP::Event<VWPP::IntSignal>::wakeAll().

Clone this wiki locally