P99
Related Functions

Set a flag and notify other threads that an event has occurred. More...

#include <p99_notifier.h>

Related Functions

(Note that these are not member functions.)

void p99_notifier_block (p99_notifier volatile *p00_n, unsigned p00_v)
 Block until the notification flag has been set to the indicated value. More...
 
void p99_notifier_destroy (p99_notifier *p00_n)
 destroy a notifier More...
 
p99_notifierp99_notifier_init (p99_notifier *p00_n, unsigned p00_v)
 Initialize a notifier to value p00_v. More...
 
unsigned p99_notifier_load (p99_notifier volatile *p00_n)
 Return the value of the notifier. Non blocking. More...
 

Detailed Description

Set a flag and notify other threads that an event has occurred.

Such a variable stores a state and enables threads to wait for a certain value of that state.

Per default, the state space that is used are just the values 0 and 1 but other values that are compatible with unsigned or int, e.g enumeration types, could be used as well.

The state with value 0 is special and should not be waited for.

A typical example could be a herd of threads. Let us suppose that we have a main thread that launches such a herd:

for (size_t i = 0; i < n; ++i)
start_my_threads(i, &all_started);
p99_notifier_set(&all_started);
// ... do something clever ...
// ... join all the threads ...

Then every thread should just block on that notifier at the beginning of its function

int my_thread_function(void* arg) {
p99_notifier* all = arg;
...
}
See also
p99_notifier_set
p99_notifier_block
p99_notifier_load
p99_notifier_unset

Definition at line 76 of file p99_notifier.h.


The documentation for this struct was generated from the following file:
p99_notifier::p99_notifier_block
void p99_notifier_block(p99_notifier volatile *p00_n, unsigned p00_v)
Block until the notification flag has been set to the indicated value.
Definition: p99_notifier.h:117
p99_notifier
Set a flag and notify other threads that an event has occurred.
Definition: p99_notifier.h:76
P99_NOTIFIER_INITIALIZER
#define P99_NOTIFIER_INITIALIZER
Initialize an p99_notifier object.
Definition: p99_notifier.h:135
i
P00_CLAUSE2 i(_Pragma("weak p00_getopt_comp"))(_Pragma("weak p00_getopt_comp