From 5313fb77fd8d89c99ac4147ae68a12fc45a31794 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Fri, 5 Apr 2024 16:53:51 +1100 Subject: [PATCH 1/2] ThreadPoolExecutor: Drop std::binary_semaphore polyfill. All targets we compile for should now support enough C++20 stdlib features to remove the need for us to provide a fallback. --- src/common/thread_pool_executor.cpp | 56 ----------------------------- 1 file changed, 56 deletions(-) diff --git a/src/common/thread_pool_executor.cpp b/src/common/thread_pool_executor.cpp index f73d963ebc1..d3aea60d3f7 100644 --- a/src/common/thread_pool_executor.cpp +++ b/src/common/thread_pool_executor.cpp @@ -24,62 +24,6 @@ #include #include -#include - -#ifdef __cpp_lib_semaphore -#include -#else -// Hello, there! This version of libstdc++ doesn't support the C++20 feature std::binary_semaphore -// We shall, instead, open-code the simplest possible implementation of what we use here. -namespace std -{ -class binary_semaphore -{ -public: - binary_semaphore(int initial) - : raised{initial == 1} - { - } - - void release() - { - { - std::lock_guard lock{mutex}; - raised = true; - } - cv.notify_all(); - } - - void acquire() - { - std::unique_lock lock{mutex}; - if (raised) - { - raised = false; - return; - } - cv.wait(lock, [this]() { return raised; }); - raised = false; - } - - bool try_acquire() - { - std::lock_guard lock{mutex}; - if (raised) - { - raised = false; - return true; - } - return false; - } -private: - std::mutex mutex; - std::condition_variable cv; - bool raised; -}; -} -#endif - namespace { constexpr int const min_threadpool_threads = 4; From d36c200742072a48cd84782a97ea99a3a95cbdcb Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Mon, 8 Apr 2024 11:49:18 +1000 Subject: [PATCH 2/2] ThreadPoolExecutor: Oops, actually `#include ` It's tranitively included from somewhere else, but we explicitly use it so we should explicitly `#include` it. --- src/common/thread_pool_executor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/thread_pool_executor.cpp b/src/common/thread_pool_executor.cpp index d3aea60d3f7..ed41274da90 100644 --- a/src/common/thread_pool_executor.cpp +++ b/src/common/thread_pool_executor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace {