58 lines
1.2 KiB
C++
58 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;
|
|
}
|
|
|
|
#if 0
|
|
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);
|
|
}
|
|
#endif
|
|
} |