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

Function check_wait_self_deadlock

tests/BS_thread_pool_test.cpp:1593–1612  ·  view source on GitHub ↗

* @brief Check that calling wait() from within a thread of the same pool throws an exception instead of creating a deadlock. */

Source from the content-addressed store, hash-verified

1591 * @brief Check that calling wait() from within a thread of the same pool throws an exception instead of creating a deadlock.
1592 */
1593void check_wait_self_deadlock()
1594{
1595 constexpr std::chrono::milliseconds sleep_time(100);
1596 logln("Checking for deadlocks when waiting from within a thread of the same pool...");
1597 std::atomic<bool> passed = false;
1598 check_wait_self_deadlock_pool.detach_task(
1599 [&passed]
1600 {
1601 try
1602 {
1603 check_wait_self_deadlock_pool.wait();
1604 }
1605 catch (const BS::wait_deadlock&)
1606 {
1607 passed = true;
1608 }
1609 });
1610 check_wait_self_deadlock_pool.wait_for(sleep_time);
1611 check(passed);
1612}
1613#endif
1614
1615// ========================================

Callers 1

mainFunction · 0.85

Calls 4

loglnFunction · 0.85
checkFunction · 0.85
waitMethod · 0.80
wait_forMethod · 0.80

Tested by

no test coverage detected