MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / WaitUntil

Function WaitUntil

tensorflow/lite/experimental/ruy/wait.cc:22–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace ruy {
21
22void WaitUntil(const std::function<bool()>& condition,
23 const Duration& spin_duration, std::condition_variable* condvar,
24 std::mutex* mutex) {
25 // First, trivial case where the `condition` is already true;
26 if (condition()) {
27 return;
28 }
29
30 // Then try busy-waiting.
31 const TimePoint wait_start = Now();
32 while (Now() - wait_start < spin_duration) {
33 if (condition()) {
34 return;
35 }
36 }
37
38 // Finally, do real passive waiting.
39 std::unique_lock<std::mutex> lock(*mutex);
40 condvar->wait(lock, condition);
41}
42
43void WaitUntil(const std::function<bool()>& condition,
44 std::condition_variable* condvar, std::mutex* mutex) {

Callers 3

WaitMethod · 0.85
ThreadFuncImplMethod · 0.85
WaitTestFunction · 0.85

Calls 4

NowFunction · 0.85
DurationFromMillisecondsFunction · 0.85
conditionFunction · 0.50
waitMethod · 0.45

Tested by 1

WaitTestFunction · 0.68