| 46 | |
| 47 | template <typename T> |
| 48 | auto waiting_function(T result, size_t milliseconds, |
| 49 | StartStopSignal* signal = nullptr) { |
| 50 | return [result, signal, milliseconds]() { |
| 51 | if (signal) { |
| 52 | // signal that the operation has started |
| 53 | signal->hasStartedSignal_.notify(); |
| 54 | } |
| 55 | std::this_thread::sleep_for(std::chrono::milliseconds{milliseconds}); |
| 56 | if (signal) { |
| 57 | // wait for the test case to allow finishing the operation |
| 58 | signal->mayFinishSignal_.wait(); |
| 59 | } |
| 60 | return result; |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | auto wait_and_throw_function(size_t milliseconds, |
| 65 | StartStopSignal* signal = nullptr) { |