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

55 lines
1.3 KiB
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.
2022-11-17 07:46:07 +00:00
File: AuSemaphore.Generic.hpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-12
Author: Reece
***/
#pragma once
2021-09-06 10:58:08 +00:00
#if defined(AURORA_IS_MODERNNT_DERIVED)
2022-11-17 07:46:07 +00:00
#include "AuSemaphore.NT.hpp"
#elif defined(AURORA_IS_LINUX_DERIVED)
#include "AuSemaphore.Linux.hpp"
2021-06-27 21:25:29 +00:00
#else
#define _AURUNTIME_GENERIC_SEMAPHORE
namespace Aurora::Threading::Primitives
{
struct SemaphoreGeneric : ISemaphore
2021-06-27 21:25:29 +00:00
{
SemaphoreGeneric(AuUInt16 uIntialValue = 0);
~SemaphoreGeneric();
auline bool TryLockNoSpin();
auline bool TryLockHeavy();
bool TryLock() override;
2021-06-27 21:25:29 +00:00
bool HasOSHandle(AuMach &mach) override;
2021-06-27 21:25:29 +00:00
bool HasLockImplementation() override;
2021-06-27 21:25:29 +00:00
void Unlock() override;
void Unlock(AuUInt16 uThreads) override;
void Lock() override;
bool LockMS(AuUInt64 qwTimeout) override;
bool LockAbsMS(AuUInt64 qwTimeout) override;
bool LockNS(AuUInt64 qwTimeout) override;
bool LockAbsNS(AuUInt64 qwTimeoutAbs) override;
AuAUInt32 uAtomicState {};
AuAUInt32 uAtomicSleeping {};
2021-06-27 21:25:29 +00:00
};
using SemaphoreImpl = SemaphoreGeneric;
2021-06-27 21:25:29 +00:00
}
#endif