Bitcoin Core 30.99.0
P2P Digital Currency
Classes | Macros | Functions | Variables
threadpool_tests.cpp File Reference
#include <common/system.h>
#include <logging.h>
#include <random.h>
#include <test/util/common.h>
#include <util/string.h>
#include <util/threadpool.h>
#include <util/time.h>
#include <boost/test/unit_test.hpp>
#include <latch>
#include <semaphore>
Include dependency graph for threadpool_tests.cpp:

Go to the source code of this file.

Classes

struct  ThreadPoolFixture
 

Macros

#define WAIT_FOR(futures)
 

Functions

template<typename F >
auto Submit (ThreadPool &pool, F &&fn)
 
std::vector< std::future< void > > BlockWorkers (ThreadPool &threadPool, std::counting_semaphore<> &release_sem, size_t num_of_threads_to_block)
 
 BOOST_AUTO_TEST_CASE (submit_fails_with_correct_error)
 
 BOOST_AUTO_TEST_CASE (submit_tasks_complete_successfully)
 
 BOOST_AUTO_TEST_CASE (single_available_worker_executes_all_tasks)
 
 BOOST_AUTO_TEST_CASE (wait_for_task_to_finish)
 
 BOOST_AUTO_TEST_CASE (get_result_from_completed_task)
 
 BOOST_AUTO_TEST_CASE (task_exception_propagates_to_future)
 
 BOOST_AUTO_TEST_CASE (process_tasks_manually_when_workers_busy)
 
 BOOST_AUTO_TEST_CASE (recursive_task_submission)
 
 BOOST_AUTO_TEST_CASE (task_submitted_while_busy_completes)
 
 BOOST_AUTO_TEST_CASE (congestion_more_workers_than_cores)
 
 BOOST_AUTO_TEST_CASE (interrupt_blocks_new_submissions)
 
 BOOST_AUTO_TEST_CASE (start_mid_stop_does_not_deadlock)
 
 BOOST_AUTO_TEST_CASE (queued_tasks_complete_after_interrupt)
 
 BOOST_AUTO_TEST_CASE (stop_active_wait_drains_queue)
 

Variables

int NUM_WORKERS_DEFAULT = 0
 
constexpr char POOL_NAME [] = "test"
 
constexpr auto WAIT_TIMEOUT = 120s
 

Macro Definition Documentation

◆ WAIT_FOR

#define WAIT_FOR (   futures)
Value:
do { \
for (const auto& f : futures) { \
BOOST_REQUIRE(f.wait_for(WAIT_TIMEOUT) == std::future_status::ready); \
} \
} while (0)
constexpr auto WAIT_TIMEOUT

Definition at line 46 of file threadpool_tests.cpp.

Function Documentation

◆ BlockWorkers()

std::vector< std::future< void > > BlockWorkers ( ThreadPool threadPool,
std::counting_semaphore<> &  release_sem,
size_t  num_of_threads_to_block 
)

Definition at line 62 of file threadpool_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/14]

BOOST_AUTO_TEST_CASE ( congestion_more_workers_than_cores  )

Definition at line 294 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/14]

BOOST_AUTO_TEST_CASE ( get_result_from_completed_task  )

Definition at line 178 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/14]

BOOST_AUTO_TEST_CASE ( interrupt_blocks_new_submissions  )

Definition at line 315 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/14]

BOOST_AUTO_TEST_CASE ( process_tasks_manually_when_workers_busy  )

Definition at line 211 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/14]

BOOST_AUTO_TEST_CASE ( queued_tasks_complete_after_interrupt  )

Definition at line 382 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/14]

BOOST_AUTO_TEST_CASE ( recursive_task_submission  )

Definition at line 242 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/14]

BOOST_AUTO_TEST_CASE ( single_available_worker_executes_all_tasks  )

Definition at line 138 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/14]

BOOST_AUTO_TEST_CASE ( start_mid_stop_does_not_deadlock  )

Definition at line 348 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/14]

BOOST_AUTO_TEST_CASE ( stop_active_wait_drains_queue  )

Definition at line 410 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/14]

BOOST_AUTO_TEST_CASE ( submit_fails_with_correct_error  )

Definition at line 76 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/14]

BOOST_AUTO_TEST_CASE ( submit_tasks_complete_successfully  )

Definition at line 113 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/14]

BOOST_AUTO_TEST_CASE ( task_exception_propagates_to_future  )

Definition at line 191 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/14]

BOOST_AUTO_TEST_CASE ( task_submitted_while_busy_completes  )

Definition at line 259 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [14/14]

BOOST_AUTO_TEST_CASE ( wait_for_task_to_finish  )

Definition at line 164 of file threadpool_tests.cpp.

Here is the call graph for this function:

◆ Submit()

template<typename F >
auto Submit ( ThreadPool pool,
F &&  fn 
)

Definition at line 55 of file threadpool_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ NUM_WORKERS_DEFAULT

int NUM_WORKERS_DEFAULT = 0

Definition at line 18 of file threadpool_tests.cpp.

◆ POOL_NAME

constexpr char POOL_NAME[] = "test"
constexpr

Definition at line 19 of file threadpool_tests.cpp.

◆ WAIT_TIMEOUT

constexpr auto WAIT_TIMEOUT = 120s
constexpr

Definition at line 20 of file threadpool_tests.cpp.