AuroraRuntime/Source/Threading/Primitives/CriticalSection.hpp

31 lines
696 B
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: CriticalSection.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
#include "Mutex.Generic.hpp"
namespace Aurora::Threading::Primitives
{
2022-06-01 21:49:38 +00:00
struct CriticalSection : IWaitable
2021-06-27 21:25:29 +00:00
{
CriticalSection();
~CriticalSection();
bool HasOSHandle(AuMach &mach) override;
bool HasLockImplementation() override;
bool TryLock() override;
void Lock() override;
bool Lock(AuUInt64 timeout) override;
void Unlock() override;
private:
Mutex mutex_;
Threads::IAuroraThread *owner_;
std::atomic<int> count_;
};
}