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

Method acquire

Libraries/Threading/Threading.cpp:137–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135SC::Semaphore::Semaphore(int initialCount) : count(initialCount) {}
136
137void SC::Semaphore::acquire()
138{
139 mutex.lock();
140 while (count == 0)
141 {
142 condition.wait(mutex);
143 }
144 --count;
145 mutex.unlock();
146}
147
148void SC::Semaphore::release()
149{

Callers 1

testSemaphoreMethod · 0.80

Calls 3

lockMethod · 0.45
waitMethod · 0.45
unlockMethod · 0.45

Tested by 1

testSemaphoreMethod · 0.64