30static void GetFuture(std::future<void>& future, uint32_t& fail_counter)
37 assert(
false &&
"Unexpected exception type");
77 std::atomic_uint32_t task_counter{0};
78 uint32_t fail_counter{0};
79 uint32_t expected_task_counter{0};
80 uint32_t expected_fail_tasks{0};
82 std::queue<std::future<void>> futures;
83 for (uint32_t i = 0; i < num_tasks; ++i) {
87 std::future<void> fut;
89 expected_fail_tasks++;
92 expected_task_counter++;
97 if (wait_immediately) {
103 futures.emplace(std::move(fut));
108 while (!futures.empty()) {
109 auto fut = std::move(futures.front());
115 assert(task_counter.load() == expected_task_counter);
116 assert(fail_counter == expected_fail_tasks);
void DisableLogging() EXCLUSIVE_LOCKS_REQUIRED(!m_cs)
Disable logging This offers a slight speedup and slightly smaller memory usage compared to leaving th...
T ConsumeIntegralInRange(T min, T max)
Fixed-size thread pool for running arbitrary tasks concurrently.
void Start(int num_workers) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Start worker threads.
size_t WorkersCount() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
size_t WorkQueueSize() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
BCLog::Logger & LogInstance()
std::atomic_uint32_t & m_counter
CounterTask(std::atomic_uint32_t &counter)
ExpectedException(const std::string &msg)
static void setup_threadpool_test()
static void GetFuture(std::future< void > &future, uint32_t &fail_counter)
static void StartPoolIfNeeded() EXCLUSIVE_LOCKS_REQUIRED(!g_pool_mutex)
FUZZ_TARGET(threadpool,.init=setup_threadpool_test) EXCLUSIVE_LOCKS_REQUIRED(!g_pool_mutex)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
FuzzedDataProvider & fuzzed_data_provider