diff --git a/include/components/controller.hpp b/include/components/controller.hpp index 30624edf..3deb404a 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -2,6 +2,7 @@ #include +#include #include #include diff --git a/include/modules/meta/base.hpp b/include/modules/meta/base.hpp index 9e40f2b1..5fc75e88 100644 --- a/include/modules/meta/base.hpp +++ b/include/modules/meta/base.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -17,6 +18,7 @@ POLYBAR_NS namespace chrono = std::chrono; using namespace std::chrono_literals; +using std::atomic; using std::map; #define DEFAULT_FORMAT "format" diff --git a/include/utils/concurrency.hpp b/include/utils/concurrency.hpp index 3fde2613..6f34e4c7 100644 --- a/include/utils/concurrency.hpp +++ b/include/utils/concurrency.hpp @@ -1,8 +1,5 @@ #pragma once -#include -#include -#include #include #include @@ -11,41 +8,12 @@ POLYBAR_NS -namespace chrono =std::chrono; using namespace std::chrono_literals; namespace this_thread = std::this_thread; -using std::atomic; -using std::map; using std::mutex; using std::thread; -class spin_lock : public non_copyable_mixin { - public: - struct no_backoff_strategy { - bool operator()(); - }; - struct yield_backoff_strategy { - bool operator()(); - }; - - public: - explicit spin_lock() = default; - - template - void lock(Backoff backoff) noexcept { - while (m_locked.test_and_set(std::memory_order_acquire)) { - backoff(); - } - } - - void lock() noexcept; - void unlock() noexcept; - - protected: - std::atomic_flag m_locked{false}; -}; - template class mutex_wrapper : public T { public: diff --git a/include/x11/tray_manager.hpp b/include/x11/tray_manager.hpp index 018d3552..3f66b024 100644 --- a/include/x11/tray_manager.hpp +++ b/include/x11/tray_manager.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -31,6 +32,7 @@ POLYBAR_NS namespace chrono = std::chrono; using namespace std::chrono_literals; +using std::atomic; // fwd declarations class connection; diff --git a/src/utils/concurrency.cpp b/src/utils/concurrency.cpp index ee320aff..55f62e0b 100644 --- a/src/utils/concurrency.cpp +++ b/src/utils/concurrency.cpp @@ -1,31 +1,19 @@ #include "utils/concurrency.hpp" -POLYBAR_NS +#include -bool spin_lock::no_backoff_strategy::operator()() { - return true; -} -bool spin_lock::yield_backoff_strategy::operator()() { - this_thread::yield(); - return false; -} -void spin_lock::lock() noexcept { - lock(no_backoff_strategy{}); -} -void spin_lock::unlock() noexcept { - m_locked.clear(std::memory_order_release); -} +POLYBAR_NS namespace concurrency_util { size_t thread_id(const thread::id id) { static size_t idx{1_z}; - static mutex_wrapper> ids; + static mutex_wrapper> ids; std::lock_guard lock(ids); if (ids.find(id) == ids.end()) { ids[id] = idx++; } return ids[id]; } -} +} // namespace concurrency_util POLYBAR_NS_END