Reece Wilson
433898709e
[*] _beginthreadex returns null, nonex returns -1, and it doesnt fucking work with affinity but seems to work with name updates. i dont care to fix this yet. fuck microsoft. [*] NT: preempt process watch thread of leaders instead of syncing to the process under a watch guard on free (evil, we should use a builtin nt threadpool. also cant be arsed to resolve)
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: LSMutex.NT.cpp
|
|
Date: 2021-10-1
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "LSMutex.hpp"
|
|
|
|
namespace Aurora::IO::Loop
|
|
{
|
|
LSMutex::LSMutex(HANDLE handle) : LSHandle(AuReinterpretCast<AuUInt>(handle))
|
|
{}
|
|
|
|
LSMutex::~LSMutex()
|
|
{
|
|
auto handle = reinterpret_cast<HANDLE>(this->handle);
|
|
AuWin32CloseHandle(handle);
|
|
this->handle = kInvalidHandle;
|
|
}
|
|
|
|
bool LSMutex::Unlock()
|
|
{
|
|
return ReleaseMutex(reinterpret_cast<HANDLE>(handle));
|
|
}
|
|
|
|
bool LSMutex::IsSignaled()
|
|
{
|
|
return LSHandle::IsSignaled();
|
|
}
|
|
|
|
bool LSMutex::WaitOn(AuUInt32 timeout)
|
|
{
|
|
return LSHandle::WaitOn(timeout);
|
|
}
|
|
|
|
ELoopSource LSMutex::GetType()
|
|
{
|
|
return ELoopSource::eSourceMutex;
|
|
}
|
|
|
|
AUKN_SYM AuSPtr<ILSMutex> NewLSMutex()
|
|
{
|
|
AuSPtr<ILSMutex> ret;
|
|
|
|
auto mutex = ::CreateMutexW(NULL, false, NULL);
|
|
if (!mutex)
|
|
{
|
|
SysPushErrorGen("Out of OS resources?");
|
|
return {};
|
|
}
|
|
|
|
return AuMakeShared<LSMutex>(mutex);
|
|
}
|
|
} |