P99

◆ P99_SPIN_EXCLUDE

#define P99_SPIN_EXCLUDE (   FLAGP)    P00_SPIN_EXCLUDE(FLAGP, P99_UNIQ(flg))

Protect the following block or statement as a critical section of the program by using FLAGP as a spinlock.

Parameters
FLAGPis an expression that evaluates to a pointer to ::atomic_flag. The flag is used as a spinlock, so this is an active wait.
Remarks
FLAGP is only evaluated once at the beginning, so it would be safe to change it in the depending block or statement.
Warning
Such a section should only contain a handful of statements.
Such a section should not contain preliminary exits such as goto, break, return, longjmp, or P99_UNWIND etc.

Such a critical section is only protected against threads that try to enter this same critical section. Threads may well simultaneously be in different critical sections.

See also
P99_MUTUAL_EXCLUDE that is more suited for larger sections.

Definition at line 90 of file p99_atomic_flag.h.