mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 13:01:27 +12:00
lf_queue: implement wait() method
Synchronization does not occupy additional space by reusing LSB
This commit is contained in:
parent
ac775cd75e
commit
81c50bad69
3 changed files with 53 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "cond.h"
|
||||
#include "sync.h"
|
||||
#include "lockless.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -267,3 +268,27 @@ void cond_x16::imp_notify() noexcept
|
|||
|
||||
balanced_awaken(m_cvx16, utils::popcnt16(wait_mask));
|
||||
}
|
||||
|
||||
bool lf_queue_base::wait(u64 _timeout)
|
||||
{
|
||||
return balanced_wait_until(m_head, _timeout, [](std::uintptr_t& head, auto... ret) -> int
|
||||
{
|
||||
if (head != 1)
|
||||
{
|
||||
return +1;
|
||||
}
|
||||
|
||||
if constexpr (sizeof...(ret))
|
||||
{
|
||||
head = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void lf_queue_base::imp_notify()
|
||||
{
|
||||
balanced_awaken(m_head, 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue