MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / wait

Method wait

deps/memkind/src/test/performance/framework.cpp:45–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#endif
44
45 void Barrier::wait()
46 {
47 unique_lock<mutex> lock(m_barrierMutex);
48 // Decrement number of threads awaited at the barrier
49 m_waiting--;
50 if (m_waiting == 0) {
51 // Called by the last expected thread - notify all waiting threads and exit
52 m_cVar.notify_all();
53 // Store the time when barrier was released
54 if (m_releasedAt.tv_sec == 0 && m_releasedAt.tv_nsec == 0) {
55 clock_gettime(CLOCK_MONOTONIC, &m_releasedAt);
56 }
57 return;
58 }
59 // Wait unitl the last expected thread calls wait() on Barrier instance, or timeout occurs
60 m_cVar.wait_until(lock, ch::system_clock::now() + ch::seconds(10), []() {
61 return GetInstance().m_waiting == 0;
62 });
63 }
64
65 // Worker class
66 Worker::Worker(

Callers 6

WorkerThreadMainMethod · 0.45
timeThreadMainFunction · 0.45
acquireReadMethod · 0.45
acquireWriteMethod · 0.45
workMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected