[+] AuIO::Loop::NewLSIOHandle(const AuSPtr<IIOHandle> &pHandle)
[-] Rip 2021-10-1 LSCondVar
This commit is contained in:
parent
f13efd0cbf
commit
f2339bb0a9
@ -58,9 +58,6 @@ namespace Aurora::IO::Loop
|
|||||||
virtual void *GetLastSignalInfo() = 0;
|
virtual void *GetLastSignalInfo() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
AUKN_SYM AuSPtr<IConditionVar> NewLSCondVar(const AuSPtr<Threading::IWaitable> &primitive);
|
|
||||||
AUKN_SYM AuSPtr<IConditionVar> NewLSCondVar(const AuSPtr<ILSMutex> &source);
|
|
||||||
|
|
||||||
AUKN_SYM AuSPtr<ITimer> NewLSTimer(AuUInt64 absStartTimeMs /*CurrentClockMS()*/, AuUInt32 reschedStepMsOrZero = 0, AuUInt32 maxIterationsOrZero = 0, bool bSingleshot = false /*cannot be changed*/);
|
AUKN_SYM AuSPtr<ITimer> NewLSTimer(AuUInt64 absStartTimeMs /*CurrentClockMS()*/, AuUInt32 reschedStepMsOrZero = 0, AuUInt32 maxIterationsOrZero = 0, bool bSingleshot = false /*cannot be changed*/);
|
||||||
AUKN_SYM AuSPtr<ILSMutex> NewLSMutex();
|
AUKN_SYM AuSPtr<ILSMutex> NewLSMutex();
|
||||||
AUKN_SYM AuSPtr<ILSEvent> NewLSEvent(bool triggerd = false, bool atomicRelease = true, bool permitMultipleTriggers = false);
|
AUKN_SYM AuSPtr<ILSEvent> NewLSEvent(bool triggerd = false, bool atomicRelease = true, bool permitMultipleTriggers = false);
|
||||||
@ -71,6 +68,7 @@ namespace Aurora::IO::Loop
|
|||||||
AUKN_SYM AuSPtr<ILoopSource> NewStdIn();
|
AUKN_SYM AuSPtr<ILoopSource> NewStdIn();
|
||||||
AUKN_SYM AuSPtr<ILoopSource> NewLSWin32Source(bool dispatchMessages);
|
AUKN_SYM AuSPtr<ILoopSource> NewLSWin32Source(bool dispatchMessages);
|
||||||
AUKN_SYM AuSPtr<ILoopSource> NewLSAppleSource();
|
AUKN_SYM AuSPtr<ILoopSource> NewLSAppleSource();
|
||||||
|
AUKN_SYM AuSPtr<ILoopSource> NewLSIOHandle(const AuSPtr<IIOHandle> &pHandle);
|
||||||
|
|
||||||
#if defined(X_PROTOCOL)
|
#if defined(X_PROTOCOL)
|
||||||
static AuSPtr<ILoopSource> NewLSX11(Display *display)
|
static AuSPtr<ILoopSource> NewLSX11(Display *display)
|
||||||
|
@ -99,6 +99,7 @@ namespace Aurora::IO::IPC
|
|||||||
|
|
||||||
this->fsHandle_->InitFromMove((AuUInt)this->GetPipeHandle());
|
this->fsHandle_->InitFromMove((AuUInt)this->GetPipeHandle());
|
||||||
AuStaticCast<AFileHandle>(this->fsHandle_)->bIsAsync = true;
|
AuStaticCast<AFileHandle>(this->fsHandle_)->bIsAsync = true;
|
||||||
|
AuStaticCast<AFileHandle>(this->fsHandle_)->pIPCPipe = this;
|
||||||
|
|
||||||
this->fsStream_->Init(this->fsHandle_);
|
this->fsStream_->Init(this->fsHandle_);
|
||||||
|
|
||||||
@ -171,8 +172,7 @@ namespace Aurora::IO::IPC
|
|||||||
|
|
||||||
AuSPtr<Loop::ILoopSource> IPCPipeImpl::AsReadChannelHasData()
|
AuSPtr<Loop::ILoopSource> IPCPipeImpl::AsReadChannelHasData()
|
||||||
{
|
{
|
||||||
// TODO (Hack): we should at least make a shared timer
|
return this->SharedFromThis();
|
||||||
return AuUnsafeRaiiToShared(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AuSPtr<IO::IAsyncTransaction> IPCPipeImpl::NewAsyncTransaction()
|
AuSPtr<IO::IAsyncTransaction> IPCPipeImpl::NewAsyncTransaction()
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/***
|
|
||||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
||||||
|
|
||||||
File: LSCondition.cpp
|
|
||||||
Date: 2021-10-1
|
|
||||||
Author: Reece
|
|
||||||
***/
|
|
||||||
#include <Source/RuntimeInternal.hpp>
|
|
||||||
#include "LSCondition.hpp"
|
|
||||||
|
|
||||||
namespace Aurora::IO::Loop
|
|
||||||
{
|
|
||||||
AUKN_SYM AuSPtr<IConditionVar> NewLSCondVar(const AuSPtr<AuThreading::IWaitable> &primitive)
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
AUKN_SYM AuSPtr<IConditionVar> NewLSCondVar(const AuSPtr<ILSMutex> &source)
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
/***
|
|
||||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
||||||
|
|
||||||
File: LSCondition.hpp
|
|
||||||
Date: 2021-10-1
|
|
||||||
Author: Reece
|
|
||||||
***/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace Aurora::IO::Loop
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
96
Source/IO/Loop/LSIOHandle.cpp
Normal file
96
Source/IO/Loop/LSIOHandle.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: LSIOHandle.cpp
|
||||||
|
Date: 2023-9-16
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#include <Source/RuntimeInternal.hpp>
|
||||||
|
#include "Loop.hpp"
|
||||||
|
#include "LSIOHandle.hpp"
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
#include <Source/IO/AuIOHandle.hpp>
|
||||||
|
#include <Source/IO/IPC/AuIPCPipe.NT.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Aurora::IO::Loop
|
||||||
|
{
|
||||||
|
LSIOHandle::LSIOHandle()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
LSIOHandle::LSIOHandle(const AuSPtr<IIOHandle> &pHandle) : pHandle(pHandle)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
bool LSIOHandle::OnTrigger(AuUInt handle)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AuList<AuUInt> &LSIOHandle::GetHandles()
|
||||||
|
{
|
||||||
|
static AuList<AuUInt> kDummyArray;
|
||||||
|
return kDummyArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||||
|
|
||||||
|
const AuList<AuUInt> &LSIOHandle::GetWriteHandles()
|
||||||
|
{
|
||||||
|
static AuList<AuUInt> kDummyArray;
|
||||||
|
return kDummyArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuUInt LSIOHandle::GetWriteHandle()
|
||||||
|
{
|
||||||
|
return this->pHandle->GetOSWriteHandleSafe().ValueOr(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AuUInt LSIOHandle::GetHandle()
|
||||||
|
{
|
||||||
|
return this->pHandle->GetOSReadHandleSafe().ValueOr(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LSIOHandle::Singular()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ELoopSource LSIOHandle::GetType()
|
||||||
|
{
|
||||||
|
return ELoopSource::eSourceHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
AUKN_SYM AuSPtr<ILoopSource> NewLSIOHandle(const AuSPtr<IIOHandle> &pHandle)
|
||||||
|
{
|
||||||
|
if (!pHandle)
|
||||||
|
{
|
||||||
|
SysPushErrorArg();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
if (pHandle->IsPipe())
|
||||||
|
{
|
||||||
|
if (auto pIPCPipe = AuStaticCast<AFileHandle>(pHandle)->pIPCPipe)
|
||||||
|
{
|
||||||
|
return pIPCPipe->AsReadChannelHasData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SysPushErrorResourceInvalid("Use the loop source provided by the IPC pipe class.");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pHandle->IsTTY())
|
||||||
|
{
|
||||||
|
SysPushErrorResourceInvalid("Use the loop source provided by AuConsole::StdInBufferLoopSource() or AuLoop::NewStdIn(). If this is a PTY, you're out of luck.");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return AuMakeShared<LSIOHandle>(pHandle);
|
||||||
|
}
|
||||||
|
}
|
39
Source/IO/Loop/LSIOHandle.hpp
Normal file
39
Source/IO/Loop/LSIOHandle.hpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: LSIOHandle.hpp
|
||||||
|
Date: 2023-9-16
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "WaitSingle.hpp"
|
||||||
|
|
||||||
|
namespace Aurora::IO::Loop
|
||||||
|
{
|
||||||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
static constexpr auto kInvalidHandle = (AuUInt)INVALID_HANDLE_VALUE;
|
||||||
|
#else
|
||||||
|
static constexpr auto kInvalidHandle = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct LSIOHandle : virtual WaitSingleGeneric
|
||||||
|
{
|
||||||
|
LSIOHandle();
|
||||||
|
LSIOHandle(const AuSPtr<IIOHandle> &pHandle);
|
||||||
|
|
||||||
|
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;
|
||||||
|
#endif
|
||||||
|
virtual ELoopSource GetType() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AuSPtr<IIOHandle> pHandle;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user