thread/spinlock: assert the lock isn't held at destruction
This commit is contained in:
parent
747cfa9237
commit
2153feafc1
@ -21,16 +21,28 @@ spinlock::spinlock ():
|
|||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
spinlock::~spinlock ()
|
||||||
|
{
|
||||||
|
CHECK (!held);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
spinlock::spinlock (spinlock &&rhs) noexcept:
|
spinlock::spinlock (spinlock &&rhs) noexcept:
|
||||||
held (rhs.held.load ())
|
held (rhs.held.load ())
|
||||||
{ ; }
|
{
|
||||||
|
rhs.held = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
spinlock& spinlock::operator= (spinlock &&rhs) noexcept
|
spinlock& spinlock::operator= (spinlock &&rhs) noexcept
|
||||||
{
|
{
|
||||||
|
CHECK (!held);
|
||||||
|
|
||||||
held = rhs.held.load ();
|
held = rhs.held.load ();
|
||||||
|
rhs.held = false;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ namespace cruft::thread {
|
|||||||
class spinlock {
|
class spinlock {
|
||||||
public:
|
public:
|
||||||
spinlock ();
|
spinlock ();
|
||||||
|
~spinlock ();
|
||||||
|
|
||||||
spinlock (spinlock &&) noexcept;
|
spinlock (spinlock &&) noexcept;
|
||||||
spinlock& operator= (spinlock &&) noexcept;
|
spinlock& operator= (spinlock &&) noexcept;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user