| 883 | public: |
| 884 | TestSemaphore(T initialValue) : _lastValue(std::move(initialValue)) {} |
| 885 | void waitForValue(T expectedValue) { |
| 886 | // Flush the queue first before trying to compare the values |
| 887 | while (_taskQueue.runNextTask()) { |
| 888 | } |
| 889 | |
| 890 | while (_lastValue != expectedValue) { |
| 891 | auto success = _taskQueue.runNextTask(std::chrono::steady_clock::now() + std::chrono::seconds(5)); |
| 892 | if (!success) { |
| 893 | throw Exception(STRING_FORMAT("Failed to wait until value becomes {}", expectedValue)); |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | void setValue(T value) { |
| 899 | _taskQueue.enqueue([this, value]() { |
no test coverage detected