From 3f15963651a21ec09b14107f8e87eb8c376c8dae Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Tue, 17 Nov 2020 09:40:34 +0100 Subject: [PATCH] Remove SpinLock No longer needed as its only user now uses std::mutex. --- lib/base/CMakeLists.txt | 1 - lib/base/spinlock.cpp | 22 ---------------------- lib/base/spinlock.hpp | 35 ----------------------------------- 3 files changed, 58 deletions(-) delete mode 100644 lib/base/spinlock.cpp delete mode 100644 lib/base/spinlock.hpp diff --git a/lib/base/CMakeLists.txt b/lib/base/CMakeLists.txt index c1f28a06d..108ca27c1 100644 --- a/lib/base/CMakeLists.txt +++ b/lib/base/CMakeLists.txt @@ -64,7 +64,6 @@ set(base_SOURCES shared-object.hpp singleton.hpp socket.cpp socket.hpp - spinlock.cpp spinlock.hpp stacktrace.cpp stacktrace.hpp statsfunction.hpp stdiostream.cpp stdiostream.hpp diff --git a/lib/base/spinlock.cpp b/lib/base/spinlock.cpp deleted file mode 100644 index 03de2e6be..000000000 --- a/lib/base/spinlock.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* Icinga 2 | (c) 2020 Icinga GmbH | GPLv2+ */ - -#include "base/spinlock.hpp" -#include - -using namespace icinga; - -void SpinLock::lock() -{ - while (m_Locked.test_and_set(std::memory_order_acquire)) { - } -} - -bool SpinLock::try_lock() -{ - return !m_Locked.test_and_set(std::memory_order_acquire); -} - -void SpinLock::unlock() -{ - m_Locked.clear(std::memory_order_release); -} diff --git a/lib/base/spinlock.hpp b/lib/base/spinlock.hpp deleted file mode 100644 index d6da5876e..000000000 --- a/lib/base/spinlock.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Icinga 2 | (c) 2020 Icinga GmbH | GPLv2+ */ - -#ifndef SPINLOCK_H -#define SPINLOCK_H - -#include - -namespace icinga -{ - -/** - * A spin lock. - * - * @ingroup base - */ -class SpinLock -{ -public: - SpinLock() = default; - SpinLock(const SpinLock&) = delete; - SpinLock& operator=(const SpinLock&) = delete; - SpinLock(SpinLock&&) = delete; - SpinLock& operator=(SpinLock&&) = delete; - - void lock(); - bool try_lock(); - void unlock(); - -private: - std::atomic_flag m_Locked = ATOMIC_FLAG_INIT; -}; - -} - -#endif /* SPINLOCK_H */