SPU: Cache reservation memory direct access handle (optimization)

This commit is contained in:
Eladash 2021-12-03 17:28:39 +02:00 committed by Ivan
parent 1458349cb3
commit 3dda72e47f
2 changed files with 64 additions and 31 deletions

View file

@ -276,8 +276,8 @@ public:
}
// Wait for both thread sync var and provided atomic var
template <atomic_wait::op Op = atomic_wait::op::eq, typename T, typename U>
static inline void wait_on(T& wait, U old, u64 usec = -1)
template <uint Max, typename Func>
static inline void wait_on_custom(Func&& setter, u64 usec = -1)
{
auto _this = g_tls_this_thread;
@ -286,13 +286,19 @@ public:
return;
}
atomic_wait::list<3> list{};
list.set<0, Op>(wait, old);
list.set<1>(_this->m_sync, 0, 4 + 1);
list.set<2>(_this->m_taskq, nullptr);
atomic_wait::list<Max + 2> list{};
list.template set<Max>(_this->m_sync, 0, 4 + 1);
list.template set<Max + 1>(_this->m_taskq, nullptr);
setter(list);
list.wait(atomic_wait_timeout{usec <= 0xffff'ffff'ffff'ffff / 1000 ? usec * 1000 : 0xffff'ffff'ffff'ffff});
}
template <atomic_wait::op Op = atomic_wait::op::eq, typename T, typename U>
static inline void wait_on(T& wait, U old, u64 usec = -1)
{
wait_on_custom<1>([&](atomic_wait::list<3>& list){ list.set<0, Op>(wait, old); }, usec);
}
// Exit.
[[noreturn]] static void emergency_exit(std::string_view reason);