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

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

Callers 1

testSemaphoreMethod · 0.80

Calls 3

lockMethod · 0.45
waitMethod · 0.45
unlockMethod · 0.45

Tested by 1

testSemaphoreMethod · 0.64