lock fixes
This commit is contained in:
parent
98eeb765fd
commit
4eb03ad017
|
@ -86,7 +86,7 @@ struct UniqueLock {
|
|||
UniqueLock(): p_mtx(nullptr), p_owns(false) {}
|
||||
|
||||
explicit UniqueLock(MutexType &m): p_mtx(&m), p_owns(true) {
|
||||
m->lock();
|
||||
m.lock();
|
||||
}
|
||||
|
||||
UniqueLock(MutexType &m, DeferLock): p_mtx(&m), p_owns(false) {}
|
||||
|
@ -139,6 +139,13 @@ struct UniqueLock {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool unlock() {
|
||||
if (!p_mtx || p_owns) return false;
|
||||
bool ret = p_mtx->unlock();
|
||||
if (ret) p_owns = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void swap(UniqueLock &u) {
|
||||
detail::swap_adl(p_mtx, u.p_mtx);
|
||||
detail::swap_adl(p_owns, u.p_owns);
|
||||
|
|
|
@ -71,6 +71,10 @@ namespace this_thread {
|
|||
inline void yield() {
|
||||
thrd_yield();
|
||||
}
|
||||
|
||||
inline void exit() {
|
||||
thrd_exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
|
Loading…
Reference in a new issue