Chapter 5

Events

Events provide a way to signal to other threads that an event has occurred.

5.1  Functions

void avr_thread_event_set_wake_one(volatile avr_thread_event* event)   function

This function places the given event, event in a signaled state. If there are threads waiting on this event, the thread that has been waiting the longest is awakened.

While the event is signaled, a thread that calls avr_thread_event_wait() or avr_thread_event_wait_and_clear() will return immediately.

void avr_thread_event_set_wake_all(volatile avr_thread_event* event)   function

This function places the given event, event in a signaled state. If there are threads waiting on this event, all of them are awakened.

While the event is signaled, a thread that calls avr_thread_event_wait() or avr_thread_event_wait_and_clear() will return immediately.

void avr_thread_event_clear(volatile avr_thread_event* event)   function

This function clears the given event, event. While the event is clear, a thread that calls avr_thread_event_wait() or avr_thread_event_wait_and_clear() will block until the event is signaled.

uint8_t avr_thread_event_wait(volatile avr_thread_event* event, uint16_t ticks)   function

This function waits for the given event, event, to become signaled.

If the event is signaled when this function is called, this function returns 1 immediately. Otherwise, the thread is blocked until the event is signaled by another thread.

While blocked, if the thread is awakened by another thread through a call to avr_thread_event_set_wake_all() or avr_thread_event_set_wake_one(), then this function returns 1. Otherwise, if the given number of ticks, ticks, elapses, the function times-out and returns 0.

If you pass ticks as zero, this function will wait indefinitely until the event becomes signaled.

uint8_t avr_thread_event_wait_and_clear(volatile avr_thread_event* event, uint16_t ticks)   function

This function waits for the given event, event, to become signaled.

If the event is signaled when this function is called, this function clears the event and returns 1 immediately. Otherwise, the thread is blocked until the event is signaled by another thread.

While blocked, if the thread is awakened by another thread through a call to avr_thread_event_set_wake_all() or avr_thread_event_set_wake_one(), then this function clears the event and returns 1. Otherwise, if the given number of ticks, ticks, elapses, the function times-out and returns 0.

If you pass ticks as zero, this function will wait indefinitely until the event becomes signaled.

struct avr_thread_event   structure

This structure is used by the AVR Threads Library to hold event data. It should be treated as an opaque object.