AuroraRuntime/Source/Threading/Primitives/AuSemaphore.NT.hpp

37 lines
944 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: AuSemaphore.NT.hpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-12
Author: Reece
***/
#pragma once
2023-03-15 02:38:26 +00:00
#include "AuConditionMutex.Generic.hpp"
#include "AuConditionVariable.NT.hpp"
2021-06-27 21:25:29 +00:00
namespace Aurora::Threading::Primitives
{
struct SemaphoreImpl final : ISemaphore
2021-06-27 21:25:29 +00:00
{
SemaphoreImpl(AuUInt16 uIntialValue = 0);
~SemaphoreImpl();
2021-06-27 21:25:29 +00:00
bool HasOSHandle(AuMach &mach) override;
bool HasLockImplementation() override;
bool TryLock() override;
bool LockMS(AuUInt64 timeout) override;
bool LockNS(AuUInt64 timeout) override;
2021-06-27 21:25:29 +00:00
void Lock() override;
void Unlock(AuUInt16 count) override;
2021-06-27 21:25:29 +00:00
void Unlock() override;
auline bool TryLockNoSpin();
auline bool TryLockHeavy();
2021-06-27 21:25:29 +00:00
private:
AuUInt32 dwState_ {};
2023-03-15 02:38:26 +00:00
ConditionMutexImpl mutex;
ConditionVariableImpl var;
2021-06-27 21:25:29 +00:00
};
}