AuroraRuntime/Source/Threading/Primitives/AuConditionMutex.NT.hpp
Reece 046b70d7bc [*] [Pre-Win8.1] Optimize for modern nt instead of windows vista synch in legacy path; yes, this is how windows 7 and vista synch is somewhat implemented.
...on apis that predate those kernel revisions. so, technically this might be able to run on xp.
[*] GetThreadCookie optimization for all platforms
2023-03-15 00:35:29 +00:00

40 lines
895 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
{
AuUInt32 uWaitCount {}; // yields while bits are high, dec to release one from the semaphore yield
};
struct Win32ConditionMutex : IConditionMutexEx
{
Win32ConditionMutex();
~Win32ConditionMutex();
bool TryLock() override;
void Lock() override;
void Unlock() override;
AuUInt GetOSHandle() override;
NT4Mutex lock_;
};
using ConditionMutexImpl = Win32ConditionMutex;
}
#endif