mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 22:41:12 +01:00
ircd::ctx: Various assertions for current context.
This commit is contained in:
parent
a776565ce0
commit
77dc612735
2 changed files with 16 additions and 0 deletions
|
@ -94,6 +94,7 @@ ircd::ctx::mutex::unlock()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::mutex::lock()
|
ircd::ctx::mutex::lock()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
deadlock_assertion();
|
deadlock_assertion();
|
||||||
|
|
||||||
q.wait([this]
|
q.wait([this]
|
||||||
|
@ -115,6 +116,7 @@ template<class time_point>
|
||||||
bool
|
bool
|
||||||
ircd::ctx::mutex::try_lock_until(const time_point &tp)
|
ircd::ctx::mutex::try_lock_until(const time_point &tp)
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
deadlock_assertion();
|
deadlock_assertion();
|
||||||
|
|
||||||
const bool success
|
const bool success
|
||||||
|
@ -135,6 +137,7 @@ inline bool
|
||||||
ircd::ctx::mutex::try_lock()
|
ircd::ctx::mutex::try_lock()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
deadlock_assertion();
|
deadlock_assertion();
|
||||||
|
|
||||||
if(locked())
|
if(locked())
|
||||||
|
|
|
@ -131,6 +131,7 @@ ircd::ctx::shared_mutex::unlock_upgrade_and_lock_shared()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::unlock_upgrade_and_lock()
|
ircd::ctx::shared_mutex::unlock_upgrade_and_lock()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
assert(u == current);
|
assert(u == current);
|
||||||
|
|
||||||
q.wait([this]
|
q.wait([this]
|
||||||
|
@ -144,6 +145,7 @@ ircd::ctx::shared_mutex::unlock_upgrade_and_lock()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::unlock_and_lock_upgrade()
|
ircd::ctx::shared_mutex::unlock_and_lock_upgrade()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
assert(u == current);
|
assert(u == current);
|
||||||
assert(s == std::numeric_limits<decltype(s)>::min());
|
assert(s == std::numeric_limits<decltype(s)>::min());
|
||||||
|
|
||||||
|
@ -153,6 +155,7 @@ ircd::ctx::shared_mutex::unlock_and_lock_upgrade()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::unlock_and_lock_shared()
|
ircd::ctx::shared_mutex::unlock_and_lock_shared()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
assert(u == current);
|
assert(u == current);
|
||||||
assert(s == std::numeric_limits<decltype(s)>::min());
|
assert(s == std::numeric_limits<decltype(s)>::min());
|
||||||
|
|
||||||
|
@ -163,6 +166,7 @@ ircd::ctx::shared_mutex::unlock_and_lock_shared()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::unlock_upgrade()
|
ircd::ctx::shared_mutex::unlock_upgrade()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
assert(u == current);
|
assert(u == current);
|
||||||
|
|
||||||
u = nullptr;
|
u = nullptr;
|
||||||
|
@ -181,6 +185,7 @@ ircd::ctx::shared_mutex::unlock_shared()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::unlock()
|
ircd::ctx::shared_mutex::unlock()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
assert(u == current);
|
assert(u == current);
|
||||||
assert(s == std::numeric_limits<decltype(s)>::min());
|
assert(s == std::numeric_limits<decltype(s)>::min());
|
||||||
|
|
||||||
|
@ -255,6 +260,7 @@ ircd::ctx::shared_mutex::try_unlock_shared_and_lock_upgrade()
|
||||||
inline bool
|
inline bool
|
||||||
ircd::ctx::shared_mutex::try_unlock_shared_and_lock()
|
ircd::ctx::shared_mutex::try_unlock_shared_and_lock()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
if(s != 1)
|
if(s != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -267,6 +273,7 @@ ircd::ctx::shared_mutex::try_unlock_shared_and_lock()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::lock_upgrade()
|
ircd::ctx::shared_mutex::lock_upgrade()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
q.wait([this]
|
q.wait([this]
|
||||||
{
|
{
|
||||||
return can_lock_upgrade();
|
return can_lock_upgrade();
|
||||||
|
@ -289,6 +296,7 @@ ircd::ctx::shared_mutex::lock_shared()
|
||||||
inline void
|
inline void
|
||||||
ircd::ctx::shared_mutex::lock()
|
ircd::ctx::shared_mutex::lock()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
q.wait([this]
|
q.wait([this]
|
||||||
{
|
{
|
||||||
return can_lock();
|
return can_lock();
|
||||||
|
@ -323,6 +331,7 @@ template<class time_point>
|
||||||
bool
|
bool
|
||||||
ircd::ctx::shared_mutex::try_lock_upgrade_until(time_point&& tp)
|
ircd::ctx::shared_mutex::try_lock_upgrade_until(time_point&& tp)
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
const bool can_lock_upgrade
|
const bool can_lock_upgrade
|
||||||
{
|
{
|
||||||
q.wait_until(tp, [this]
|
q.wait_until(tp, [this]
|
||||||
|
@ -341,6 +350,7 @@ template<class time_point>
|
||||||
bool
|
bool
|
||||||
ircd::ctx::shared_mutex::try_lock_shared_until(time_point&& tp)
|
ircd::ctx::shared_mutex::try_lock_shared_until(time_point&& tp)
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
const bool can_lock_shared
|
const bool can_lock_shared
|
||||||
{
|
{
|
||||||
q.wait_until(tp, [this]
|
q.wait_until(tp, [this]
|
||||||
|
@ -359,6 +369,7 @@ template<class time_point>
|
||||||
bool
|
bool
|
||||||
ircd::ctx::shared_mutex::try_lock_until(time_point&& tp)
|
ircd::ctx::shared_mutex::try_lock_until(time_point&& tp)
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
const bool can_lock
|
const bool can_lock
|
||||||
{
|
{
|
||||||
q.wait_until(tp, [this]
|
q.wait_until(tp, [this]
|
||||||
|
@ -379,6 +390,7 @@ ircd::ctx::shared_mutex::try_lock_until(time_point&& tp)
|
||||||
inline bool
|
inline bool
|
||||||
ircd::ctx::shared_mutex::try_lock_upgrade()
|
ircd::ctx::shared_mutex::try_lock_upgrade()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
if(can_lock_upgrade())
|
if(can_lock_upgrade())
|
||||||
{
|
{
|
||||||
u = current;
|
u = current;
|
||||||
|
@ -397,6 +409,7 @@ ircd::ctx::shared_mutex::try_lock_shared()
|
||||||
inline bool
|
inline bool
|
||||||
ircd::ctx::shared_mutex::try_lock()
|
ircd::ctx::shared_mutex::try_lock()
|
||||||
{
|
{
|
||||||
|
assert(current);
|
||||||
if(can_lock())
|
if(can_lock())
|
||||||
{
|
{
|
||||||
u = current;
|
u = current;
|
||||||
|
|
Loading…
Reference in a new issue