/*** Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Overlapped.hpp Date: 2023-1-26 Author: Reece Note: Defer to Async.hpp for creation of overlapped stream objects This header defines FS.hpp-like APIs that run overlapped or on a worker thread or two. ***/ #pragma once namespace Aurora::IO::Loop { struct ILoopSource; } namespace Aurora::IO::FS { struct IOverlappedOperationBase; AUKN_INTERFACE(IOverlappedCallback, AUI_METHOD(void, OnSuccess, (AuSPtr, pOriginator)), AUI_METHOD(void, OnFailure, (AuSPtr, pOriginator)) ); struct IOverlappedOperationBase { virtual AuSPtr ToWaitable() = 0; virtual AuSPtr SetCallback(AuSPtr pCallback) = 0; virtual bool IsOperationComplete() = 0; virtual bool IsOperationSuccessful() = 0; }; struct IOverlappedStatOperation : IOverlappedOperationBase { virtual AuSPtr GetStats() = 0; }; struct IOverlappedReadOperation : IOverlappedOperationBase { virtual AuSPtr GetByteBuffer() = 0; virtual AuSPtr GetReadView() = 0; }; /** * @brief If running under AuAsync runner, we use the local thread for the entire IO operation. * In the future, whence I can be bothered to finish the APC api, *all* overlapped operations * will be processed on the local thread. * Specifying true forces all IO to occour on a preallocated pool of IO workers * @warning this api is thread-local * @warning this api does not change the behaviour of overlapped file streamss */ AUKN_SYM bool OverlappedForceDelegatedIO(bool bForceIOWorkerThreads); AUKN_SYM AuSPtr OverlappedCompress(const AuString &path, AuInt8 iLevel = 17); AUKN_SYM AuSPtr OverlappedDecompress(const AuString &path); AUKN_SYM AuSPtr OverlappedWrite(const AuString &path, AuSPtr pMemoryView); AUKN_SYM AuSPtr OverlappedRead(const AuString &path); AUKN_SYM AuSPtr OverlappedStat(const AuString &path); AUKN_SYM AuSPtr OverlappedCopy(const AuString &path, const AuString &dest); AUKN_SYM AuSPtr OverlappedRelink(const AuString &path, const AuString &dest); AUKN_SYM AuSPtr OverlappedTrustFile(const AuString &path); AUKN_SYM AuSPtr OverlappedBlockFile(const AuString &path); AUKN_SYM AuSPtr OverlappedUnblockFile(const AuString &path); AUKN_SYM AuSPtr OverlappedDelete(const AuString &path); }