diff --git a/thread/spinlock.cpp b/thread/spinlock.cpp index 93cd176d..4d4c5652 100644 --- a/thread/spinlock.cpp +++ b/thread/spinlock.cpp @@ -21,16 +21,28 @@ spinlock::spinlock (): { ; } +//----------------------------------------------------------------------------- +spinlock::~spinlock () +{ + CHECK (!held); +} + + //----------------------------------------------------------------------------- spinlock::spinlock (spinlock &&rhs) noexcept: held (rhs.held.load ()) -{ ; } +{ + rhs.held = false; +} //----------------------------------------------------------------------------- spinlock& spinlock::operator= (spinlock &&rhs) noexcept { + CHECK (!held); + held = rhs.held.load (); + rhs.held = false; return *this; } diff --git a/thread/spinlock.hpp b/thread/spinlock.hpp index 2d6a14e5..958eb6d8 100644 --- a/thread/spinlock.hpp +++ b/thread/spinlock.hpp @@ -24,6 +24,8 @@ namespace cruft::thread { class spinlock { public: spinlock (); + ~spinlock (); + spinlock (spinlock &&) noexcept; spinlock& operator= (spinlock &&) noexcept;