Changed: atomic_wait to use while loop instead of atom.wait() because of random stalls

This commit is contained in:
aristocratos 2021-09-28 16:58:08 +02:00
parent 5fba94c96c
commit ff6d1d6eec
1 changed files with 5 additions and 5 deletions

View File

@ -269,13 +269,13 @@ namespace Tools {
string hostname();
string username();
#if __GNUC__ < 11
// #if __GNUC__ < 11
inline void atomic_wait(const atomic<bool>& atom, const bool old=true) noexcept { while (atom.load() == old) sleep_ms(1); }
inline void atomic_notify(const atomic<bool>& atom) noexcept { (void)atom; }
#else
inline void atomic_wait(const atomic<bool>& atom, const bool old=true) noexcept { atom.wait(old); }
inline void atomic_notify(const atomic<bool>& atom) noexcept { atom.notify_all(); }
#endif
// #else
// inline void atomic_wait(const atomic<bool>& atom, const bool old=true) noexcept { if (atom == old) atom.wait(old); }
// inline void atomic_notify(const atomic<bool>& atom) noexcept { atom.notify_all(); }
// #endif
//* Waits for atomic<bool> to be false and sets it to true on construct, sets to false and notifies on destruct
class atomic_lock {