AuroraRuntime/Source/Loop/LSHandle.cpp

98 lines
2.0 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: LSHandle.cpp
Date: 2021-10-1
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "LSHandle.hpp"
namespace Aurora::Loop
{
LSHandle::LSHandle()
{}
LSHandle::LSHandle(AuUInt handle) : handle(handle)
{}
LSHandle::LSHandle(AuUInt handleRd, AuUInt handleWr) : handle(handleRd), handleWr(handleWr)
{}
bool LSHandle::OnTrigger(AuUInt handle)
{
return true;
}
AuList<AuUInt> LSHandle::GetHandles()
{
return {};
}
#if defined(AURORA_IS_POSIX_DERIVED)
AuList<AuUInt> LSHandle::GetWriteHandles()
{
return {};
}
AuUInt LSHandle::GetWriteHandle()
{
return this->handleWr;
}
void LSHandle::UpdateWriteHandle(AuUInt handle)
{
this->handleWr = handle;
}
#endif
void LSHandle::UpdateReadHandle(AuUInt handle)
{
this->handle = handle;
}
AuUInt LSHandle::GetHandle()
{
return this->handle;
}
bool LSHandle::Singular()
{
return true;
}
ELoopSource LSHandle::GetType()
{
return ELoopSource::eSourceHandle;
}
bool LSHandle::HasValidHandle()
{
#if defined(AURORA_IS_POSIX_DERIVED)
return this->handle != kInvalidHandle || this->handleWr != kInvalidHandle;
#elif defined(AURORA_IS_MODERNNT_DERIVED)
return this->handle != reinterpret_cast<AuUInt>(kInvalidHandle);
#endif
}
AUKN_SYM AuSPtr<ILoopSource> NewLSOSHandle(AuUInt handle)
{
#if defined(AURORA_IS_MODERNNT_DERIVED)
if (reinterpret_cast<HANDLE>(handle) == kInvalidHandle)
{
return {};
}
#endif
#if defined(AURORA_IS_POSIX_DERIVED)
if (handle == kInvalidHandle)
{
return {};
}
#endif
return AuMakeShared<LSHandle>(handle);
}
}