atomic.cpp: improvements.

Reduced static memory amount for waitable atomics.
Allow notifier to skip notifications if wait/notify masks don't overlap.
Improve raw_notify to wake up the thread by its id, add thread_id arg.
Add optional mask argument to notify_one() and notify_all().
This commit is contained in:
Nekotekina 2020-11-04 17:19:35 +03:00
parent b66628baca
commit 5248240e10
7 changed files with 418 additions and 249 deletions

View file

@ -1900,14 +1900,15 @@ void thread_base::initialize(void (*error_cb)(), bool(*wait_cb)(const void*))
void thread_base::notify_abort() noexcept
{
m_signal.try_inc();
u64 tid = m_thread.load();
#ifdef _WIN32
tid = GetThreadId(reinterpret_cast<HANDLE>(tid));
#endif
while (auto ptr = m_state_notifier.load())
{
// Since this function is not perfectly implemented, run it in a loop
atomic_storage_futex::raw_notify(ptr);
if (m_state_notifier.load() == ptr)
if (atomic_storage_futex::raw_notify(ptr, tid))
{
break;
}