MCPcopy Create free account
hub / github.com/bshoshany/thread-pool / check_task_destruct

Function check_task_destruct

tests/BS_thread_pool_test.cpp:2700–2711  ·  view source on GitHub ↗

* @brief Check that a task is destructed immediately after it executes, and therefore does not artificially extend the lifetime of any captured objects. */

Source from the content-addressed store, hash-verified

2698 * @brief Check that a task is destructed immediately after it executes, and therefore does not artificially extend the lifetime of any captured objects.
2699 */
2700void check_task_destruct()
2701{
2702 constexpr std::chrono::milliseconds sleep_time(20);
2703 BS::thread_pool pool;
2704 std::atomic<bool> object_exists = false;
2705 {
2706 const std::shared_ptr<detect_destruct> ptr = std::make_shared<detect_destruct>(&object_exists);
2707 pool.submit_task([ptr] {}).wait();
2708 }
2709 std::this_thread::sleep_for(sleep_time);
2710 check(!object_exists);
2711}
2712
2713/**
2714 * @brief Check that the type trait `BS::common_index_type` works as expected.

Callers 1

mainFunction · 0.85

Calls 2

checkFunction · 0.85
waitMethod · 0.80

Tested by

no test coverage detected