openMSX
CondVar.cc
Go to the documentation of this file.
1 #include "CondVar.hh"
2 
3 #include <chrono>
4 
5 namespace openmsx {
6 
8 {
9  std::unique_lock<std::mutex> lock(mutex);
10  condition.wait(lock);
11 }
12 
13 bool CondVar::waitTimeout(unsigned us)
14 {
15  std::chrono::microseconds duration(us);
16  std::unique_lock<std::mutex> lock(mutex);
17  return condition.wait_for(lock, duration) == std::cv_status::timeout;
18 }
19 
21 {
22  condition.notify_one();
23 }
24 
26 {
27  condition.notify_all();
28 }
29 
30 } // namespace openmsx
void signal()
Wake on thread that's waiting on this condtition variable.
Definition: CondVar.cc:20
void signalAll()
Wake all threads that are waiting on this condition variable.
Definition: CondVar.cc:25
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void wait()
Block till another thread signals this condition variable.
Definition: CondVar.cc:7
bool waitTimeout(unsigned us)
Same as wait(), but with a timeout.
Definition: CondVar.cc:13