mirror of
https://github.com/ZDoom/Raze.git
synced 2024-12-11 13:21:49 +00:00
39 lines
No EOL
783 B
C++
39 lines
No EOL
783 B
C++
#pragma once
|
|
|
|
namespace FileSys {
|
|
// System independent critical sections without polluting the namespace with the operating system headers.
|
|
class FInternalCriticalSection;
|
|
FInternalCriticalSection *CreateCriticalSection();
|
|
void DeleteCriticalSection(FInternalCriticalSection *c);
|
|
void EnterCriticalSection(FInternalCriticalSection *c);
|
|
void LeaveCriticalSection(FInternalCriticalSection *c);
|
|
|
|
// This is just a convenience wrapper around the function interface adjusted to use std::lock_guard
|
|
class FCriticalSection
|
|
{
|
|
public:
|
|
FCriticalSection()
|
|
{
|
|
c = CreateCriticalSection();
|
|
}
|
|
|
|
~FCriticalSection()
|
|
{
|
|
DeleteCriticalSection(c);
|
|
}
|
|
|
|
void lock()
|
|
{
|
|
EnterCriticalSection(c);
|
|
}
|
|
|
|
void unlock()
|
|
{
|
|
LeaveCriticalSection(c);
|
|
}
|
|
|
|
private:
|
|
FInternalCriticalSection *c;
|
|
|
|
};
|
|
} |