* @brief Check that calling wait() from within a thread of the same pool throws an exception instead of creating a deadlock. */
| 1591 | * @brief Check that calling wait() from within a thread of the same pool throws an exception instead of creating a deadlock. |
| 1592 | */ |
| 1593 | void 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 | // ======================================== |