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

34 lines
810 B
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: AuMutex.NT.hpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-12
Author: Reece
***/
#pragma once
namespace Aurora::Threading::Primitives
{
struct MutexImpl final : IHyperWaitable
2021-06-27 21:25:29 +00:00
{
MutexImpl();
~MutexImpl();
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;
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:
#if defined(AURORA_FORCE_SRW_LOCKS)
2021-06-27 21:25:29 +00:00
SRWLOCK atomicHolder_;
CONDITION_VARIABLE wakeup_;
#endif
2021-06-27 21:25:29 +00:00
};
}