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

Function WaitTest

tensorflow/lite/experimental/ruy/wait_test.cc:65–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63};
64
65void WaitTest(const Duration& spin_duration, const Duration& delay) {
66 std::condition_variable condvar;
67 std::mutex mutex;
68 std::atomic<int> value(0);
69 std::atomic<int> end_value(0);
70 ThreadCountingUpToValue thread_callable(end_value, &value, &condvar, &mutex);
71 std::thread thread(thread_callable);
72 std::this_thread::sleep_for(delay);
73 for (int i = 1; i < 10; i++) {
74 end_value.store(1000 * i);
75 const auto& condition = [&value, &end_value]() {
76 return value.load() == end_value.load();
77 };
78 ruy::WaitUntil(condition, spin_duration, &condvar, &mutex);
79 EXPECT_EQ(value.load(), end_value.load());
80 }
81 end_value.store(-1);
82 thread.join();
83}
84
85TEST(WaitTest, WaitTestNoSpin) {
86 WaitTest(DurationFromSeconds(0), DurationFromSeconds(0));

Callers 1

TESTFunction · 0.85

Calls 3

WaitUntilFunction · 0.85
loadMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected