Thread Flags Group

Waiter groups for thread flags. More...

Detailed Description

Waiter groups for thread flags.

This API is optional and must be enabled by adding "core_thread_flags_group" to USEMODULE.

A thread flags group allows setting thread flags for an arbitrary number of threads (called waiters) at the same time. The waiters can join and leave the group at any time. An additional advantage is that the signaler (the "flags setter") is de-coupled from the list of waiters, i.e. it does not need to know which specific thread must be signaled.

Example (waiter):

static thread_flags_group_t group = THREAD_FLAGS_GROUP_INIT;

...

thread_flags_group_join(&group);

while (!some_condition_is_met()) { thread_flags_wait_any(SOME_FLAG); }

thread_flags_group_leave(&group);

Example (signaler):

fulfill_some_condition(); thread_flags_group_set(&group, SOME_FLAG);

Files

file  thread_flags_group.h
 Thread Flags Group API.
 

Data Structures

struct  thread_flags_group_t
 Thread flags group. More...
 

Macros

#define UINT_WIDTH   (sizeof(unsigned) * 8)
 Number of bits in unsigned int.
 
#define THREAD_FLAGS_GROUP_INIT   { .members = { 0 } }
 Initialize a thread flags group.
 

Functions

static void thread_flags_group_join (thread_flags_group_t *group)
 Join a thread flags group. More...
 
static void thread_flags_group_leave (thread_flags_group_t *group)
 Leave a thread flags group. More...
 
void thread_flags_group_set (thread_flags_group_t *group, thread_flags_t mask)
 Set thread flags for all threads in a group. More...
 

Function Documentation

◆ thread_flags_group_join()

static void thread_flags_group_join ( thread_flags_group_t group)
inlinestatic

Join a thread flags group.

After joining the group, the thread may call any thread_flags_wait_*() method as usual. The thread will remain in the group until thread_flags_group_leave() is called.

Parameters
[out]groupThe thread flags group to join.

Definition at line 96 of file thread_flags_group.h.

◆ thread_flags_group_leave()

static void thread_flags_group_leave ( thread_flags_group_t group)
inlinestatic

Leave a thread flags group.

After leaving the group, the thread will no longer be signaled by thread_flags_group_set().

Parameters
[out]groupThe thread flags group to leave.

Definition at line 113 of file thread_flags_group.h.

◆ thread_flags_group_set()

void thread_flags_group_set ( thread_flags_group_t group,
thread_flags_t  mask 
)

Set thread flags for all threads in a group.

Parameters
[in]groupThe thread flags group to set flags to.
[in]maskThe flags to set.