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

44 lines
1016 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuConditionMutex.NT.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
#include "AuIConditionMutexEx.hpp"
#if !defined(_AURUNTIME_GENERICCM)
namespace Aurora::Threading::Primitives
{
#define FAST_M_WAKE 256u
#define FAST_M_WAIT 512u
inline HANDLE gKeyedEventHandle { INVALID_HANDLE_VALUE };
struct NT4Mutex
{
volatile AuUInt32 uWaitCount {}; // yields while bits are high, dec to release one from the semaphore yield
};
struct Win32ConditionMutex final : IConditionMutexEx
{
Win32ConditionMutex();
~Win32ConditionMutex();
auline bool TryLock() override;
auline void Lock() override;
auline void Unlock() override;
AuUInt GetOSHandle() override;
#if !defined(AURORA_FORCE_SRW_LOCKS)
NT4Mutex lock_;
#else
SRWLOCK lock_;
#endif
};
using ConditionMutexImpl = Win32ConditionMutex;
}
#endif