AuroraRuntime/Source/IO/Loop/LSHandle.hpp
J Reece Wilson 4d4f5e2501 [+] ILoopSource::IsSignaledExt(...)
[+] ILoopSource::WaitOnExt(...)
[+] ILoopSource::WaitOnAbsExt(...)
2024-09-07 22:45:34 +01:00

115 lines
6.3 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: LSHandle.hpp
Date: 2021-10-1
Author: Reece
***/
#pragma once
#include "WaitSingle.hpp"
#define PROXY_LOOP_LOOPSOURCE_EXT_WAIT_APIS_ \
inline virtual bool WaitOnExt(AuUInt8 uFlags, AuUInt32 timeout) override \
{ \
return LSHandle::WaitOnExt(uFlags, timeout); \
} \
inline virtual bool WaitOnAbs(AuUInt64 uTimeoutAbs) override \
{ \
return LSHandle::WaitOnAbs(uTimeoutAbs); \
} \
inline virtual bool WaitOnAbsExt(AuUInt8 uFlags, AuUInt64 uTimeoutAbs) override \
{ \
return LSHandle::WaitOnAbsExt(uFlags, uTimeoutAbs); \
}
#define PROXY_LOOP_LOOPSOURCE_EXT_APIS_ \
inline virtual bool IsSignaledExt(AuUInt8 uFlags) override \
{ \
return LSHandle::IsSignaledExt(uFlags); \
} \
PROXY_LOOP_LOOPSOURCE_EXT_WAIT_APIS_
// TODO: more work required
#define PROXY_LOCAL_LOOPSOURCE_EXT_APIS_ \
inline virtual bool IsSignaledExt(AuUInt8 uFlags) override \
{ \
bool bFlagUser = uFlags & kFlagLSTryNoSpin; \
if (bFlagUser) \
{ \
return this->TryTakeNoSpin(); \
} \
else \
{ \
return this->TryTakeSpin(); \
} \
} \
inline virtual bool WaitOnExt(AuUInt8 uFlags, AuUInt32 timeout) override \
{ \
return this->WaitOn(timeout); \
} \
inline virtual bool WaitOnAbs(AuUInt64 uTimeoutAbs) override \
{ \
return this->WaitOnAbs(uTimeoutAbs); \
} \
inline virtual bool WaitOnAbsExt(AuUInt8 uFlags, AuUInt64 uTimeoutAbs) override \
{ \
if (!uTimeoutAbs) \
{ \
return this->TryTakeWaitNS(0); \
} \
else \
{ \
return this->TryTakeWaitNS(uTimeoutAbs); \
} \
} \
inline virtual bool WaitOn(AuUInt32 timeout) override \
{ \
if (!timeout) \
{ \
return this->TryTakeWaitNS(0); \
} \
else \
{ \
return this->TryTakeWaitNS(AuMSToNS<AuUInt64>(timeout) + AuTime::SteadyClockNS()); \
} \
}
namespace Aurora::IO::Loop
{
#if defined(AURORA_IS_MODERNNT_DERIVED)
static constexpr auto kInvalidHandle = (const AuUInt)-1;
#else
static constexpr auto kInvalidHandle = -1;
#endif
struct LSHandle : virtual WaitSingleGeneric
{
LSHandle();
LSHandle(AuUInt handle);
LSHandle(AuUInt handleRd, AuUInt handleWr);
virtual bool OnTrigger(AuUInt handle) override;
virtual const AuList<AuUInt> &GetHandles() override;
virtual AuUInt GetHandle() override;
virtual bool Singular() override;
#if defined(AURORA_IS_POSIX_DERIVED)
virtual const AuList<AuUInt> &GetWriteHandles() override;
virtual AuUInt GetWriteHandle() override;
void UpdateWriteHandle(AuUInt handle);
#endif
virtual ELoopSource GetType() override;
bool HasValidHandle();
void UpdateReadHandle(AuUInt handle);
protected:
AuUInt handle {kInvalidHandle};
#if defined(AURORA_IS_POSIX_DERIVED)
AuUInt handleWr {kInvalidHandle};
#endif
};
}