55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
/***
|
|
Copyright (C) 2021-2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuSemaphore.Generic.hpp
|
|
Date: 2021-6-12
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
#include "AuSemaphore.NT.hpp"
|
|
#elif defined(AURORA_IS_LINUX_DERIVED)
|
|
#include "AuSemaphore.Linux.hpp"
|
|
#else
|
|
#define _AURUNTIME_GENERIC_SEMAPHORE
|
|
|
|
namespace Aurora::Threading::Primitives
|
|
{
|
|
struct SemaphoreGeneric : ISemaphore
|
|
{
|
|
SemaphoreGeneric(AuUInt16 uIntialValue = 0);
|
|
~SemaphoreGeneric();
|
|
|
|
auline bool TryLockNoSpin();
|
|
auline bool TryLockHeavy();
|
|
|
|
bool TryLock() override;
|
|
|
|
|
|
bool HasOSHandle(AuMach &mach) override;
|
|
|
|
bool HasLockImplementation() override;
|
|
|
|
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 {};
|
|
};
|
|
|
|
using SemaphoreImpl = SemaphoreGeneric;
|
|
}
|
|
|
|
#endif |