Renamed ThreadSafeThreadPool to GlobalThreadPool. As of https://github.com/bshoshany/thread-pool/issues/112, the thread pool itself is thread-safe, so we removed the (extra, unnecessary) mutexes around it.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
a58be3ab87
commit
303e15e2d6
@ -31,7 +31,7 @@ class StreamMgr {
|
||||
*/
|
||||
std::unique_ptr<Daq> _inputStream, _outputStream;
|
||||
|
||||
ThreadSafeThreadPool _pool;
|
||||
GlobalThreadPool _pool;
|
||||
|
||||
/**
|
||||
* @brief All indata handlers are called when input data is available. Note
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
class BiquadBank : public Filter {
|
||||
std::vector<SeriesBiquad> _filters;
|
||||
vd _gains;
|
||||
ThreadSafeThreadPool _pool;
|
||||
GlobalThreadPool _pool;
|
||||
mutable std::mutex _mtx;
|
||||
|
||||
public:
|
||||
|
@ -15,7 +15,7 @@
|
||||
* channel. A channel is the result of a filtered signal
|
||||
*/
|
||||
class SLM {
|
||||
ThreadSafeThreadPool _pool;
|
||||
GlobalThreadPool _pool;
|
||||
/**
|
||||
* @brief A, C or Z weighting, depending on the pre-filter installed.
|
||||
*/
|
||||
|
@ -12,14 +12,15 @@
|
||||
std::weak_ptr<BS::thread_pool> _global_weak_pool;
|
||||
|
||||
/**
|
||||
* @brief Static storage for the mutex.
|
||||
* @brief Global mutex, used to restrict the pool creation to a single thread
|
||||
* at once.
|
||||
*/
|
||||
std::mutex ThreadSafeThreadPool::_mtx;
|
||||
std::mutex _mtx;
|
||||
|
||||
using Lck = std::scoped_lock<std::mutex>;
|
||||
using rte = std::runtime_error;
|
||||
|
||||
ThreadSafeThreadPool::ThreadSafeThreadPool() {
|
||||
GlobalThreadPool::GlobalThreadPool() {
|
||||
DEBUGTRACE_ENTER;
|
||||
Lck lck(_mtx);
|
||||
/// See if we can get it from the global ptr. If not, time to allocate it.
|
||||
|
@ -7,29 +7,20 @@
|
||||
* safely spawn threads also from other threads. Only wraps a submit() and
|
||||
* push_task for now.
|
||||
*/
|
||||
class ThreadSafeThreadPool {
|
||||
class GlobalThreadPool {
|
||||
|
||||
/**
|
||||
* @brief Shared access to the thread pool.
|
||||
*/
|
||||
std::shared_ptr<BS::thread_pool> _pool;
|
||||
/**
|
||||
* @brief Global mutex, used to restrict pool access to a single thread at
|
||||
* once.
|
||||
*/
|
||||
static std::mutex _mtx;
|
||||
|
||||
using Lck = std::scoped_lock<std::mutex>;
|
||||
ThreadSafeThreadPool(const ThreadSafeThreadPool&) = delete;
|
||||
ThreadSafeThreadPool &
|
||||
operator=(const ThreadSafeThreadPool&) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Instantiate handle to the thread pool.
|
||||
*/
|
||||
ThreadSafeThreadPool();
|
||||
|
||||
GlobalThreadPool();
|
||||
GlobalThreadPool(const GlobalThreadPool &) = default;
|
||||
GlobalThreadPool &operator=(const GlobalThreadPool &) = default;
|
||||
|
||||
/**
|
||||
* @brief Wrapper around BS::thread_pool::submit(...)
|
||||
@ -38,8 +29,6 @@ public:
|
||||
typename F, typename... A,
|
||||
typename R = std::invoke_result_t<std::decay_t<F>, std::decay_t<A>...>>
|
||||
[[nodiscard]] std::future<R> submit(F &&task, A &&...args) {
|
||||
/// Lock access to pool
|
||||
Lck lck(_mtx);
|
||||
|
||||
return _pool->submit(task, args...);
|
||||
}
|
||||
@ -47,9 +36,6 @@ public:
|
||||
* @brief Wrapper around BS::thread_pool::push_task(...)
|
||||
*/
|
||||
template <typename F, typename... A> void push_task(F &&task, A &&...args) {
|
||||
/// Lock access to pool
|
||||
Lck lck(_mtx);
|
||||
_pool->push_task(task, args...);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ class ThreadedInDataHandlerBase {
|
||||
std::atomic<bool> _thread_running{false};
|
||||
std::atomic<bool> _thread_can_safely_run{false};
|
||||
|
||||
ThreadSafeThreadPool _pool;
|
||||
GlobalThreadPool _pool;
|
||||
|
||||
/**
|
||||
* @brief Function pointer that is called when new DaqData arrives.
|
||||
|
Loading…
Reference in New Issue
Block a user