openMSX
Semaphore.cc
Go to the documentation of this file.
1 #include "Semaphore.hh"
2 
3 namespace openmsx {
4 
5 Semaphore::Semaphore(unsigned value)
6  : value(value)
7 {
8 }
9 
11 {
12  std::unique_lock<std::mutex> lock(mutex);
13  value++;
14  condition.notify_one();
15 }
16 
18 {
19  std::unique_lock<std::mutex> lock(mutex);
20  condition.wait(lock, [&]() { return value != 0; });
21  value--;
22 }
23 
24 } // namespace openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
Semaphore(unsigned value)
Definition: Semaphore.cc:5