Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Private Attributes | List of all members
cEvent Class Reference

#include <Event.h>

Public Member Functions

 cEvent (void)
 
void Set (void)
 Sets the event - releases one thread that has been waiting in Wait(). More...
 
void SetAll (void)
 Sets the event - releases all threads that have been waiting in Wait(). More...
 
bool Wait (unsigned a_TimeoutMSec)
 Waits for the event until either it is signalled, or the (relative) timeout is passed. More...
 
void Wait (void)
 Waits until the event has been set. More...
 

Private Attributes

std::condition_variable m_CondVar
 The condition variable used as the Event. More...
 
std::mutex m_Mutex
 Mutex protecting m_ShouldContinue from multithreaded access. More...
 
bool m_ShouldContinue
 Used for checking for spurious wakeups. More...
 

Detailed Description

Definition at line 17 of file Event.h.

Constructor & Destructor Documentation

◆ cEvent()

cEvent::cEvent ( void  )

Definition at line 14 of file Event.cpp.

Member Function Documentation

◆ Set()

void cEvent::Set ( void  )

Sets the event - releases one thread that has been waiting in Wait().

If there was no thread waiting, the next call to Wait() will not block.

Definition at line 52 of file Event.cpp.

◆ SetAll()

void cEvent::SetAll ( void  )

Sets the event - releases all threads that have been waiting in Wait().

If there was no thread waiting, the next call to Wait() will not block.

Definition at line 65 of file Event.cpp.

◆ Wait() [1/2]

bool cEvent::Wait ( unsigned  a_TimeoutMSec)

Waits for the event until either it is signalled, or the (relative) timeout is passed.

Returns true if the event was signalled, false if the timeout was hit or there was an error.

Definition at line 36 of file Event.cpp.

◆ Wait() [2/2]

void cEvent::Wait ( void  )

Waits until the event has been set.

If the event has been set before it has been waited for, Wait() returns immediately.

Definition at line 23 of file Event.cpp.

Member Data Documentation

◆ m_CondVar

std::condition_variable cEvent::m_CondVar
private

The condition variable used as the Event.

Definition at line 47 of file Event.h.

◆ m_Mutex

std::mutex cEvent::m_Mutex
private

Mutex protecting m_ShouldContinue from multithreaded access.

Definition at line 44 of file Event.h.

◆ m_ShouldContinue

bool cEvent::m_ShouldContinue
private

Used for checking for spurious wakeups.

Definition at line 41 of file Event.h.


The documentation for this class was generated from the following files: