MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / wait

Method wait

Libraries/Threading/Threading.cpp:110–130  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------- Barrier -------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

108// Barrier
109//-------------------------------------------------------------------------------------------------------
110void SC::Barrier::wait()
111{
112 mutex.lock();
113 const uint32_t gen = generation;
114 waitCount++;
115
116 if (waitCount == threadCount)
117 {
118 waitCount = 0;
119 generation++;
120 condition.broadcast();
121 }
122 else
123 {
124 while (gen == generation)
125 {
126 condition.wait(mutex);
127 }
128 }
129 mutex.unlock();
130}
131
132//-------------------------------------------------------------------------------------------------------
133// Semaphore

Callers 15

threadRunnerMethod · 0.45
socketClientServerMethod · 0.45
testEventObjectMethod · 0.45
testBarrierMethod · 0.45
snippetForWakeUp2Function · 0.45
mainFunction · 0.45
lockReadMethod · 0.45
lockWriteMethod · 0.45
acquireMethod · 0.45

Calls 3

lockMethod · 0.45
broadcastMethod · 0.45
unlockMethod · 0.45

Tested by 8

threadRunnerMethod · 0.36
socketClientServerMethod · 0.36
testEventObjectMethod · 0.36
testBarrierMethod · 0.36
snippetForWakeUp2Function · 0.36