Is there any information about fairness in relation to the sequence in which threads that called wait() on an atomic_flag are woken up when notify_one() is called. Are they woken-up in the exact order that they entered the wait(), FIFO so to say ?
Atomic flag variables seem to return 'always lock free'. I knew they were guaranteed to be lock free in any implementation but i am not sure about whether they still are if the wait() is used, and hence some mechanism must decide on waiters wake-up. Some other synchronization means guarantee fairness but it comes at a cost of memory allocation behind the scene.
Is there anyone that knows how this works with atomic_flags. I changed all my synchro's to use atomic flag and they work super fast. However I overlooked the fairness aspect.
Thank you.
The C++ standard makes no requirements here - each implementation is free to wake the thread it finds most appropriate.
This is something you might want to compare across the compilers that exist for your platforms, if it matters to you.