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

42 lines
1.1 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021-2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
2021-06-27 21:25:29 +00:00
File: Mutex.Generic.hpp
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 "AuMutex.NT.hpp"
#elif defined(AURORA_IS_LINUX_DERIVED)
#include "AuMutex.Linux.hpp"
2021-06-27 21:25:29 +00:00
#else
#define _AURUNTIME_GENERIC_MUTEX
2021-06-27 21:25:29 +00:00
namespace Aurora::Threading::Primitives
{
struct MutexGenericImpl final : IHyperWaitable
2021-06-27 21:25:29 +00:00
{
MutexGenericImpl();
~MutexGenericImpl();
2021-06-27 21:25:29 +00:00
bool HasOSHandle(AuMach &mach) override;
bool TryLock() override;
bool HasLockImplementation() override;
void SlowLock() override;
bool LockMS(AuUInt64 timeout) override;
bool LockNS(AuUInt64 timeout) override;
bool LockAbsNS(AuUInt64 uTimeout) 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 dwSleeping_ {};
2021-06-27 21:25:29 +00:00
};
using MutexImpl = MutexGenericImpl;
2021-06-27 21:25:29 +00:00
}
#endif