0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 14:31:11 +01:00

ircd::ctx: Various assertions for current context.

This commit is contained in:
Jason Volk 2020-05-01 15:16:37 -07:00
parent a776565ce0
commit 77dc612735
2 changed files with 16 additions and 0 deletions

View file

@ -94,6 +94,7 @@ ircd::ctx::mutex::unlock()
inline void
ircd::ctx::mutex::lock()
{
assert(current);
deadlock_assertion();
q.wait([this]
@ -115,6 +116,7 @@ template<class time_point>
bool
ircd::ctx::mutex::try_lock_until(const time_point &tp)
{
assert(current);
deadlock_assertion();
const bool success
@ -135,6 +137,7 @@ inline bool
ircd::ctx::mutex::try_lock()
noexcept
{
assert(current);
deadlock_assertion();
if(locked())

View file

@ -131,6 +131,7 @@ ircd::ctx::shared_mutex::unlock_upgrade_and_lock_shared()
inline void
ircd::ctx::shared_mutex::unlock_upgrade_and_lock()
{
assert(current);
assert(u == current);
q.wait([this]
@ -144,6 +145,7 @@ ircd::ctx::shared_mutex::unlock_upgrade_and_lock()
inline void
ircd::ctx::shared_mutex::unlock_and_lock_upgrade()
{
assert(current);
assert(u == current);
assert(s == std::numeric_limits<decltype(s)>::min());
@ -153,6 +155,7 @@ ircd::ctx::shared_mutex::unlock_and_lock_upgrade()
inline void
ircd::ctx::shared_mutex::unlock_and_lock_shared()
{
assert(current);
assert(u == current);
assert(s == std::numeric_limits<decltype(s)>::min());
@ -163,6 +166,7 @@ ircd::ctx::shared_mutex::unlock_and_lock_shared()
inline void
ircd::ctx::shared_mutex::unlock_upgrade()
{
assert(current);
assert(u == current);
u = nullptr;
@ -181,6 +185,7 @@ ircd::ctx::shared_mutex::unlock_shared()
inline void
ircd::ctx::shared_mutex::unlock()
{
assert(current);
assert(u == current);
assert(s == std::numeric_limits<decltype(s)>::min());
@ -255,6 +260,7 @@ ircd::ctx::shared_mutex::try_unlock_shared_and_lock_upgrade()
inline bool
ircd::ctx::shared_mutex::try_unlock_shared_and_lock()
{
assert(current);
if(s != 1)
return false;
@ -267,6 +273,7 @@ ircd::ctx::shared_mutex::try_unlock_shared_and_lock()
inline void
ircd::ctx::shared_mutex::lock_upgrade()
{
assert(current);
q.wait([this]
{
return can_lock_upgrade();
@ -289,6 +296,7 @@ ircd::ctx::shared_mutex::lock_shared()
inline void
ircd::ctx::shared_mutex::lock()
{
assert(current);
q.wait([this]
{
return can_lock();
@ -323,6 +331,7 @@ template<class time_point>
bool
ircd::ctx::shared_mutex::try_lock_upgrade_until(time_point&& tp)
{
assert(current);
const bool can_lock_upgrade
{
q.wait_until(tp, [this]
@ -341,6 +350,7 @@ template<class time_point>
bool
ircd::ctx::shared_mutex::try_lock_shared_until(time_point&& tp)
{
assert(current);
const bool can_lock_shared
{
q.wait_until(tp, [this]
@ -359,6 +369,7 @@ template<class time_point>
bool
ircd::ctx::shared_mutex::try_lock_until(time_point&& tp)
{
assert(current);
const bool can_lock
{
q.wait_until(tp, [this]
@ -379,6 +390,7 @@ ircd::ctx::shared_mutex::try_lock_until(time_point&& tp)
inline bool
ircd::ctx::shared_mutex::try_lock_upgrade()
{
assert(current);
if(can_lock_upgrade())
{
u = current;
@ -397,6 +409,7 @@ ircd::ctx::shared_mutex::try_lock_shared()
inline bool
ircd::ctx::shared_mutex::try_lock()
{
assert(current);
if(can_lock())
{
u = current;