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

View file

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