CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CYBWin32Semaphore.cpp
Go to the documentation of this file.
1 #include "CYB.hpp"
3 
4 using namespace CYB::Platform::Win32;
5 
7  FServiceCount(1),
8  FWakeCount(0),
9  FSleepCount(0)
10 {
11  Core().FModuleManager.Call<Modules::Kernel32::InitializeCriticalSection>(&FCritSection);
12  Core().FModuleManager.Call<Modules::Kernel32::InitializeConditionVariable>(&FCondVar);
13 }
14 
16  //See https://stackoverflow.com/questions/28975958/why-does-windows-have-no-deleteconditionvariable-function-to-go-together-with
17  Core().FModuleManager.Call<Modules::Kernel32::DeleteCriticalSection>(&FCritSection);
18 }
19 
21  Core().FModuleManager.Call<Modules::Kernel32::EnterCriticalSection>(&FCritSection);
22 }
23 
25  Core().FModuleManager.Call<Modules::Kernel32::LeaveCriticalSection>(&FCritSection);
26 }
27 
29  API::Assert::LessThan(0, Core().FModuleManager.Call<Modules::Kernel32::SleepConditionVariableCS>(&FCondVar, &FCritSection, INFINITE));
30 }
31 
33  Core().FModuleManager.Call<Modules::Kernel32::WakeAllConditionVariable>(&FCondVar);
34 }
35 
37  Core().FModuleManager.Call<Modules::Kernel32::WakeConditionVariable>(&FCondVar);
38 }
void Unlock(void) noexcept
Unlock the mutex associated with the CV.
void WakeOne(void) noexcept
Wake one thread waiting on the condition variable.
Platform::Modules::Manager FModuleManager
Loads and contains required modules.
Definition: CYBCore.hpp:20
static void LessThan(const AType &ALHS, const AType &ARHS) noexcept
Less than assertion function. May not be evaluated.
void Lock(void) noexcept
Lock the mutex associated with the CV.
void WakeAll(void) noexcept
Wake all threads waiting on the condition variable.
Win32::CONDITION_VARIABLE FCondVar
The condition variable.
Semaphore()
Construct a Semaphore.
~Semaphore()
Destroy a Semaphore. Semaphore must have no waiters.
Precompiled header for inter-engine operations.
Win32::CRITICAL_SECTION FCritSection
The mutex.
Engine::Core & Core(void) noexcept
Retrieve the Core singleton.
Definition: CYBCore.cpp:69
auto Call(AArgs &&...AArguments)
Call a loaded function.
void EnterCV(void) noexcept
Enter the condition variable.