mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 21:11:25 +12:00
Add cond_variable::wait_unlock
This commit is contained in:
parent
4bef0f8dab
commit
bc87c5808c
2 changed files with 11 additions and 18 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "Atomic.h"
|
||||
#include <shared_mutex>
|
||||
|
||||
// Lightweight condition variable
|
||||
class cond_variable
|
||||
|
@ -32,6 +33,15 @@ public:
|
|||
return res;
|
||||
}
|
||||
|
||||
// Unlock all specified objects but don't lock them again
|
||||
template <typename... Locks>
|
||||
bool wait_unlock(u64 usec_timeout, Locks&&... locks)
|
||||
{
|
||||
const u32 _old = m_value.fetch_add(1); // Increment waiter counter
|
||||
(..., std::forward<Locks>(locks).unlock());
|
||||
return imp_wait(_old, usec_timeout);
|
||||
}
|
||||
|
||||
// Wake one thread
|
||||
void notify_one() noexcept
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue