MCPcopy Create free account
hub / github.com/Snapchat/Valdi / blockingWaitWithTimeout

Method blockingWaitWithTimeout

valdi/src/valdi/runtime/Utils/AsyncGroup.cpp:84–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84bool AsyncGroup::blockingWaitWithTimeout(const std::chrono::steady_clock::duration& maxTime) {
85 std::unique_lock<Mutex> guard(_mutex);
86 if (_enterCount == 0) {
87 return true;
88 }
89
90 auto cond = makeShared<ConditionVariable>();
91
92 while (_enterCount != 0) {
93 auto functionId = lockFreeEnqueueFunction([cond]() { cond->notifyAll(); });
94
95 auto status = cond->waitFor(guard, maxTime);
96
97 lockFreeRemoveFunction(functionId);
98
99 if (status == std::cv_status::timeout) {
100 return false;
101 }
102 }
103
104 return true;
105}
106
107int AsyncGroup::lockFreeEnqueueFunction(DispatchFunction function) {
108 auto id = ++_callbackSequence;

Callers 6

TESTFunction · 0.80
TEST_PMethod · 0.80
waitForResultMethod · 0.80
waitForANRMethod · 0.80
waitForNextTickMethod · 0.80
TESTFunction · 0.80

Calls 2

notifyAllMethod · 0.80
waitForMethod · 0.80

Tested by 6

TESTFunction · 0.64
TEST_PMethod · 0.64
waitForResultMethod · 0.64
waitForANRMethod · 0.64
waitForNextTickMethod · 0.64
TESTFunction · 0.64