AuroraRuntime/Include/Aurora/IO/IIOProcessor.hpp

81 lines
4.0 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IIOProcessor.hpp
Date: 2022-6-6
Author: Reece
***/
#pragma once
namespace Aurora::IO::Loop
{
struct ILoopQueue;
struct ILoopSource;
}
namespace Aurora::IO
{
struct IIOProcessor
{
virtual AuUInt32 TryTick () = 0;
virtual AuUInt32 RunTick () = 0;
virtual AuUInt32 TickFor (const AuSPtr<IIOProcessorItem> &ioEvent) = 0;
virtual AuUInt32 ManualTick () = 0;
virtual AuUInt64 SetRefreshRate (AuUInt64 ns) = 0;
virtual bool HasRefreshRate () = 0;
virtual bool MultiplexRefreshRateWithIOEvents() = 0;
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;
// Inter-frame callbacks indicating point of execution throughout the [START](optional [yield])[IO][IO TICK][WORK ITEMS][EPILOGUE][END OF FRAME] frame
virtual bool AddEventListener (const AuSPtr<IIOProcessorEventListener> &eventListener) = 0;
virtual void RemoveEventListener (const AuSPtr<IIOProcessorEventListener> &eventListener) = 0;
virtual AuSPtr<IIOPipeProcessor> ToPipeProcessor () = 0;
// Reference loop queue
virtual AuSPtr<Loop::ILoopQueue> ToQueue () = 0;
virtual void ReleaseAllWatches () = 0;
virtual bool HasItems () = 0;
};
/**
* @brief Creates an IOProcessor to execute tasks on a given loop queue
* @param bTickOnly True if kernel yielding on IO objects is disabled in favor of forced TPS.
* Do note that the throughput of a tick will differ per platform. Accept rate,
* throughput, etc may need tweaking, if you wish to drive an IIOProcessor using
* a timer or the manual tick functions.
* @param pQueue
* @return
*/
AUKN_SYM AuSPtr<IIOProcessor> NewIOProcessor(bool bTickOnly, const AuSPtr<Loop::ILoopQueue> &pQueue);
/**
* @brief Creates an IOProcessor to execute tasks on the loop queue of a given AuAsync thread id
* @param bTickOnly True if kernel yielding on IO objects is disabled in favor of forced TPS.
* Do note that the throughput of a tick will differ per platform. Accept rate,
* throughput, etc may need tweaking, if you wish to drive an IIOProcessor using
* a timer or the manual tick functions.
* @param pQueue
* @return
*/
AUKN_SYM AuSPtr<IIOProcessor> NewIOProcessorOnThread(bool bTickOnly, Async::WorkerPId_t id);
AUKN_SYM AuSPtr<IIOProcessor> NewIOProcessorNoQueue(bool bTickOnly);
}