Cuberite
A lightweight, fast and extensible game server for Minecraft
Event.h
Go to the documentation of this file.
1 
2 // Event.h
3 
4 // Interfaces to the cEvent object representing a synchronization primitive that can be waited-for
5 // Implemented using C++11 condition variable and mutex
6 
7 
8 
9 
10 
11 #pragma once
12 
13 
14 
15 
16 
17 class cEvent
18 {
19 public:
20  cEvent(void);
21 
24  void Wait(void);
25 
28  void Set(void);
29 
32  void SetAll(void);
33 
36  bool Wait(unsigned a_TimeoutMSec);
37 
38 private:
39 
42 
44  std::mutex m_Mutex;
45 
47  std::condition_variable m_CondVar;
48 } ;
49 
50 
51 
52 
53 
Definition: Event.h:18
void Wait(void)
Waits until the event has been set.
Definition: Event.cpp:23
bool m_ShouldContinue
Used for checking for spurious wakeups.
Definition: Event.h:41
std::mutex m_Mutex
Mutex protecting m_ShouldContinue from multithreaded access.
Definition: Event.h:44
void SetAll(void)
Sets the event - releases all threads that have been waiting in Wait().
Definition: Event.cpp:65
cEvent(void)
Definition: Event.cpp:14
void Set(void)
Sets the event - releases one thread that has been waiting in Wait().
Definition: Event.cpp:52
std::condition_variable m_CondVar
The condition variable used as the Event.
Definition: Event.h:47