2022-12-28 23:44:45 +00:00
|
|
|
/***
|
2024-01-29 14:09:59 +00:00
|
|
|
Copyright (C) 2022-2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
2022-12-28 23:44:45 +00:00
|
|
|
|
|
|
|
File: AuSemaphore.Linux.hpp
|
|
|
|
Date: 2022-12-28
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::Threading::Primitives
|
|
|
|
{
|
2023-08-19 10:41:37 +00:00
|
|
|
struct SemaphoreImpl final : ISemaphore
|
2022-12-28 23:44:45 +00:00
|
|
|
{
|
2023-08-18 14:25:54 +00:00
|
|
|
SemaphoreImpl(AuUInt16 intialValue = 0);
|
2023-04-23 18:23:10 +00:00
|
|
|
~SemaphoreImpl();
|
2022-12-28 23:44:45 +00:00
|
|
|
|
|
|
|
bool HasOSHandle(AuMach &mach) override;
|
|
|
|
bool HasLockImplementation() override;
|
|
|
|
bool TryLock() override;
|
2023-04-03 07:21:44 +00:00
|
|
|
bool LockMS(AuUInt64 timeout) override;
|
2023-03-12 15:27:28 +00:00
|
|
|
bool LockNS(AuUInt64 timeout) override;
|
2023-08-22 14:28:09 +00:00
|
|
|
bool LockAbsMS(AuUInt64 timeout) override;
|
|
|
|
bool LockAbsNS(AuUInt64 timeout) override;
|
2022-12-28 23:44:45 +00:00
|
|
|
void Lock() override;
|
2023-08-18 14:25:54 +00:00
|
|
|
void Unlock(AuUInt16 count) override;
|
2022-12-28 23:44:45 +00:00
|
|
|
void Unlock() override;
|
|
|
|
|
2023-08-19 17:33:54 +00:00
|
|
|
auline bool TryLockNoSpin();
|
|
|
|
auline bool TryLockHeavy();
|
2022-12-28 23:44:45 +00:00
|
|
|
private:
|
2023-08-17 22:06:02 +00:00
|
|
|
AuUInt32 dwState_ {};
|
|
|
|
AuUInt32 dwSleeping_ {};
|
2022-12-28 23:44:45 +00:00
|
|
|
};
|
|
|
|
}
|