[+] Added extended IO apis
> StartSimpleLSWatchEx > StartSimpleIOWatchEx > StartIOWatchEx [*] Update README
This commit is contained in:
parent
250d3fd11e
commit
70418df761
@ -25,8 +25,13 @@ namespace Aurora::IO
|
||||
virtual AuUInt64 GetOwnedThreadId () = 0;
|
||||
|
||||
virtual AuSPtr<IIOProcessorItem> StartIOWatch (const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOEventListener> &listener) = 0;
|
||||
virtual AuSPtr<IIOProcessorItem> StartIOWatchEx (const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOEventListener> &listener, bool singleshot) = 0;
|
||||
|
||||
virtual AuSPtr<IIOProcessorItem> StartSimpleIOWatch (const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOSimpleEventListener> &listener) = 0;
|
||||
virtual AuSPtr<IIOProcessorItem> StartSimpleIOWatchEx(const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOSimpleEventListener> &listener, bool singleshot) = 0;
|
||||
|
||||
virtual AuSPtr<IIOProcessorItem> StartSimpleLSWatch (const AuSPtr<Loop::ILoopSource> &source, const AuSPtr<IIOSimpleEventListener> &listener) = 0;
|
||||
virtual AuSPtr<IIOProcessorItem> StartSimpleLSWatchEx(const AuSPtr<Loop::ILoopSource> &source, const AuSPtr<IIOSimpleEventListener> &listener, bool singleshot, AuUInt32 msTimeout = 0) = 0;
|
||||
|
||||
virtual bool SubmitIOWorkItem (const AuSPtr<IIOProcessorWorkUnit> &work) = 0;
|
||||
|
||||
|
@ -16,4 +16,5 @@ namespace Aurora::IO
|
||||
};
|
||||
|
||||
AUKN_SYM AuSPtr<IIOWatachableIOLoopSource> NewWaitableLoopSource(const AuSPtr<Loop::ILoopSource> &ptr);
|
||||
AUKN_SYM AuSPtr<IIOWatachableIOLoopSource> NewWaitableLoopSourceEx(const AuSPtr<Loop::ILoopSource>& ptr, AuUInt32 msTimeout);
|
||||
}
|
@ -24,6 +24,7 @@ namespace Aurora::IO
|
||||
|
||||
AUI_METHOD(bool, IsRunOnSelfIO, ()),
|
||||
AUI_METHOD(AuSPtr<Loop::ILoopSource>, GetSelfIOSource, ()),
|
||||
AUI_METHOD(AuUInt32, IOTimeoutInMS, ()),
|
||||
AUI_METHOD(bool, IsRunOnSelfIOCheckedOnTimerTick, ()),
|
||||
|
||||
AUI_METHOD(bool, ApplyRateLimit, ())
|
||||
|
13
README.md
13
README.md
@ -1,4 +1,5 @@
|
||||
## PREALPHA (in-dev, missing polish and APIs are volatile)
|
||||
## Minimum viable product ETA: September 2022
|
||||
|
||||
## AuroraRuntime
|
||||
|
||||
@ -50,6 +51,18 @@ Build Pipeline: [Aurora Build](https://git.reece.sx/AuroraPipeline/Build) (Lua/P
|
||||
Donate / Other Links: [Reece.SX](https://reece.sx/#contact) \
|
||||
Discord: [Invite](https://discord.gg/XYjCGWWa4J)
|
||||
|
||||
## Support
|
||||
|
||||
| Platform | Support |
|
||||
| ----------- | ------- |
|
||||
| NT/Win32-like |✅ |
|
||||
| NT/UWP | 🕖 |
|
||||
| NT/GameOS|❌ |
|
||||
| Linux |🕖 |
|
||||
| FreeBSD 9 | ❌ |
|
||||
| FreeBSD 11 | ❌ |
|
||||
| XNU/NS-like | ❌ |
|
||||
|
||||
## Performance
|
||||
|
||||
Performance of each system should ideally be that of the best implementation on the platform,
|
||||
|
@ -105,6 +105,7 @@ namespace Aurora::IO
|
||||
this->bytesWrittenLimit_ = request.lengthOrZero;
|
||||
this->asyncTransaction_ = request.asyncTransaction;
|
||||
this->asyncAdapter_ = NewAsyncStreamAdapter(request.asyncTransaction, request.isStream);
|
||||
SysAssert(this->asyncAdapter_);
|
||||
this->asyncStreamReader_ = this->asyncAdapter_->ToStreamReader();
|
||||
}
|
||||
|
||||
|
@ -297,6 +297,8 @@ namespace Aurora::IO
|
||||
}
|
||||
}
|
||||
|
||||
auto hasRemoved = this->items.crossThreadAbort.size();
|
||||
|
||||
for (auto itr = this->items.crossThreadAbort.begin(); itr != this->items.crossThreadAbort.end(); )
|
||||
{
|
||||
bool fatal = itr->second;
|
||||
@ -307,6 +309,11 @@ namespace Aurora::IO
|
||||
|
||||
itr = this->items.crossThreadAbort.erase(itr);
|
||||
}
|
||||
|
||||
if (hasRemoved)
|
||||
{
|
||||
ToQueue()->Commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -618,7 +625,8 @@ namespace Aurora::IO
|
||||
return {};
|
||||
}
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartIOWatch(const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOEventListener> &listener)
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartIOWatchEx(const AuSPtr<IIOWaitableItem>& object, const AuSPtr<IIOEventListener>& listener, bool singleshot)
|
||||
{
|
||||
if (!CheckThread())
|
||||
{
|
||||
@ -629,6 +637,7 @@ namespace Aurora::IO
|
||||
item->parent = this;
|
||||
item->listener = listener;
|
||||
item->item = object;
|
||||
item->singleshot = true;
|
||||
|
||||
AU_LOCK_GUARD(this->items.mutex);
|
||||
|
||||
@ -661,13 +670,25 @@ namespace Aurora::IO
|
||||
return {};
|
||||
}
|
||||
|
||||
auto timeout = object->IOTimeoutInMS();
|
||||
if (timeout)
|
||||
{
|
||||
if (!this->ToQueue()->SourceAddWithTimeout(src, timeout))
|
||||
{
|
||||
SysPushErrorNested("IO Error");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this->ToQueue()->SourceAdd(src))
|
||||
{
|
||||
SysPushErrorNested("IO Error");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->ToQueue()->AddCallback(src, item))
|
||||
if (!this->ToQueue()->AddCallbackEx(src, item))
|
||||
{
|
||||
SysPushErrorNested("IO Error");
|
||||
SysAssert(this->ToQueue()->SourceRemove(src));
|
||||
@ -690,7 +711,7 @@ namespace Aurora::IO
|
||||
return item;
|
||||
}
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartSimpleIOWatch(const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOSimpleEventListener> &listener)
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartSimpleIOWatchEx(const AuSPtr<IIOWaitableItem>& object, const AuSPtr<IIOSimpleEventListener>& listener, bool singleshot)
|
||||
{
|
||||
auto adapater = DesimplifyIOEventListenerAdapater(listener);
|
||||
if (!adapater)
|
||||
@ -699,19 +720,34 @@ namespace Aurora::IO
|
||||
return {};
|
||||
}
|
||||
|
||||
return this->StartIOWatch(object, adapater);
|
||||
return this->StartIOWatchEx(object, adapater, singleshot);
|
||||
}
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartSimpleLSWatch(const AuSPtr<Loop::ILoopSource> &source, const AuSPtr<IIOSimpleEventListener> &listener)
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartSimpleLSWatchEx(const AuSPtr<Loop::ILoopSource>& source, const AuSPtr<IIOSimpleEventListener>& listener, bool singleshot, AuUInt32 msTimeout)
|
||||
{
|
||||
auto sourceAdapter = NewWaitableLoopSource(source);
|
||||
auto sourceAdapter = NewWaitableLoopSourceEx(source, msTimeout);
|
||||
if (!sourceAdapter)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return {};
|
||||
}
|
||||
|
||||
return this->StartSimpleIOWatch(sourceAdapter, listener);
|
||||
return this->StartSimpleIOWatchEx(sourceAdapter, listener, singleshot);
|
||||
}
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartIOWatch(const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOEventListener> &listener)
|
||||
{
|
||||
return StartIOWatchEx(object, listener, false);
|
||||
}
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartSimpleIOWatch(const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOSimpleEventListener> &listener)
|
||||
{
|
||||
return this->StartSimpleIOWatchEx(object, listener, false);
|
||||
}
|
||||
|
||||
AuSPtr<IIOProcessorItem> IOProcessor::StartSimpleLSWatch(const AuSPtr<Loop::ILoopSource> &source, const AuSPtr<IIOSimpleEventListener> &listener)
|
||||
{
|
||||
return this->StartSimpleLSWatchEx(source, listener, false, 0);
|
||||
}
|
||||
|
||||
AuSPtr<IIOPipeProcessor> IOProcessor::ToPipeProcessor()
|
||||
|
@ -67,6 +67,11 @@ namespace Aurora::IO
|
||||
AuSPtr<IIOProcessorItem> StartSimpleIOWatch(const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOSimpleEventListener> &listener) override;
|
||||
AuSPtr<IIOProcessorItem> StartSimpleLSWatch(const AuSPtr<Loop::ILoopSource> &source, const AuSPtr<IIOSimpleEventListener> &listener) override;
|
||||
|
||||
AuSPtr<IIOProcessorItem> StartIOWatchEx (const AuSPtr<IIOWaitableItem> &object, const AuSPtr<IIOEventListener> &listener, bool singleshot) override;
|
||||
AuSPtr<IIOProcessorItem> StartSimpleIOWatchEx(const AuSPtr<IIOWaitableItem>& object, const AuSPtr<IIOSimpleEventListener>& listener, bool singleshot) override;
|
||||
AuSPtr<IIOProcessorItem> StartSimpleLSWatchEx(const AuSPtr<Loop::ILoopSource>& source, const AuSPtr<IIOSimpleEventListener>& listener, bool singleshot, AuUInt32 msTimeout) override;
|
||||
|
||||
|
||||
AuSPtr<IIOPipeProcessor> ToPipeProcessor() override;
|
||||
|
||||
AuSPtr<AuLoop::ILoopQueue> ToQueue() override;
|
||||
|
@ -36,12 +36,34 @@ namespace Aurora::IO
|
||||
return this->parent->items.ScheduleFinish(AuSharedFromThis(), true);
|
||||
}
|
||||
|
||||
bool IOProcessorItem::OnFinished(const AuSPtr<AuLoop::ILoopSource> &source)
|
||||
|
||||
bool IOProcessorItem::OnFinished(const AuSPtr<AuLoop::ILoopSource>& source, AuUInt8 pos)
|
||||
{
|
||||
if (this->singleshot)
|
||||
{
|
||||
if (AuExchange(this->triggered, true))
|
||||
{
|
||||
StopWatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
IOAlert(false);
|
||||
|
||||
if (this->singleshot)
|
||||
{
|
||||
StopWatch();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void IOProcessorItem::OnTimeout(const AuSPtr<AuLoop::ILoopSource>& source)
|
||||
{
|
||||
SysPushErrorIO("IO Timeout");
|
||||
this->FailWatch();
|
||||
}
|
||||
|
||||
void IOProcessorItem::InvokeManualTick()
|
||||
{
|
||||
IOAlert(true);
|
||||
|
@ -11,15 +11,18 @@ namespace Aurora::IO
|
||||
{
|
||||
struct IOProcessor;
|
||||
|
||||
struct IOProcessorItem : AuLoop::ILoopSourceSubscriber, IIOProcessorItem, AuEnableSharedFromThis<IOProcessorItem>
|
||||
struct IOProcessorItem : AuLoop::ILoopSourceSubscriberEx, IIOProcessorItem, AuEnableSharedFromThis<IOProcessorItem>
|
||||
{
|
||||
IOProcessor *parent;
|
||||
bool singleshot{};
|
||||
bool triggered{};
|
||||
|
||||
AuSPtr<IIOWaitableItem> item;
|
||||
AuSPtr<IIOEventListener> listener;
|
||||
|
||||
// ILoopSourceSubscriber
|
||||
bool OnFinished(const AuSPtr<AuLoop::ILoopSource> &source) override;
|
||||
bool OnFinished(const AuSPtr<AuLoop::ILoopSource> &source, AuUInt8 pos) override;
|
||||
void OnTimeout(const AuSPtr<AuLoop::ILoopSource>& source) override;
|
||||
|
||||
// IIOProcessorItem
|
||||
virtual bool StopWatch() override;
|
||||
|
@ -16,6 +16,11 @@ namespace Aurora::IO
|
||||
|
||||
}
|
||||
|
||||
IOWatachableIOLoopSource::IOWatachableIOLoopSource(const AuSPtr<Loop::ILoopSource>& source, AuUInt32 ioTimeoutMS) : source(source), ioTimeoutMS(ioTimeoutMS)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool IOWatachableIOLoopSource::IsRunOnOtherTick()
|
||||
{
|
||||
return {};
|
||||
@ -66,8 +71,18 @@ namespace Aurora::IO
|
||||
return true;
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IIOWatachableIOLoopSource> NewWaitableLoopSource(const AuSPtr<Loop::ILoopSource> &ptr)
|
||||
AuUInt32 IOWatachableIOLoopSource::IOTimeoutInMS()
|
||||
{
|
||||
return this->ioTimeoutMS;
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IIOWatachableIOLoopSource> NewWaitableLoopSource(const AuSPtr<Loop::ILoopSource>& ptr)
|
||||
{
|
||||
return AuMakeShared<IOWatachableIOLoopSource>(ptr);
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IIOWatachableIOLoopSource> NewWaitableLoopSourceEx(const AuSPtr<Loop::ILoopSource>& ptr, AuUInt32 msTimeout)
|
||||
{
|
||||
return AuMakeShared<IOWatachableIOLoopSource>(ptr, msTimeout);
|
||||
}
|
||||
}
|
@ -11,7 +11,8 @@ namespace Aurora::IO
|
||||
{
|
||||
struct IOWatachableIOLoopSource : IIOWatachableIOLoopSource
|
||||
{
|
||||
IOWatachableIOLoopSource(const AuSPtr<Loop::ILoopSource> &source);
|
||||
IOWatachableIOLoopSource(const AuSPtr<Loop::ILoopSource>& source);
|
||||
IOWatachableIOLoopSource(const AuSPtr<Loop::ILoopSource>& source, AuUInt32 ioTimeoutMS);
|
||||
|
||||
bool IsRunOnOtherTick() override;
|
||||
bool IsRunOnTick() override;
|
||||
@ -24,10 +25,12 @@ namespace Aurora::IO
|
||||
|
||||
bool ApplyRateLimit() override;
|
||||
|
||||
AuUInt32 IOTimeoutInMS() override;
|
||||
AuSPtr<Loop::ILoopSource> GetLoopSource() override;
|
||||
AuSPtr<Loop::ILoopSource> SetLoopSource(const AuSPtr<Loop::ILoopSource> &ls) override;
|
||||
bool IsRunOnSelfIOCheckedOnTimerTick() override;
|
||||
|
||||
AuSPtr<Loop::ILoopSource> source;
|
||||
AuUInt32 ioTimeoutMS{};
|
||||
};
|
||||
}
|
@ -61,6 +61,11 @@ namespace Aurora::IO
|
||||
return false;
|
||||
}
|
||||
|
||||
AuUInt32 IOWaitableIOTimer::IOTimeoutInMS()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AuUInt64 IOWaitableIOTimer::SetConstantTick(AuUInt64 ns)
|
||||
{
|
||||
auto old = AuExchange(this->constantTickNs, ns);
|
||||
|
@ -26,6 +26,8 @@ namespace Aurora::IO
|
||||
bool IsRunOnSelfIOCheckedOnTimerTick() override;
|
||||
|
||||
bool ApplyRateLimit() override;
|
||||
AuUInt32 IOTimeoutInMS() override;
|
||||
|
||||
|
||||
AuUInt64 SetConstantTick(AuUInt64 ns) override;
|
||||
AuUInt64 SetTargetTimeAbs(AuUInt64 ns) override;
|
||||
|
Loading…
Reference in New Issue
Block a user