71 lines
3.0 KiB
C++
71 lines
3.0 KiB
C++
/***
|
|
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.
|
|
|
|
**IMPL IN PROGRESS**
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::IO::Loop
|
|
{
|
|
struct ILoopSource;
|
|
}
|
|
|
|
namespace Aurora::IO::FS
|
|
{
|
|
struct IOverlappedOperationBase;
|
|
|
|
AUKN_INTERFACE(IOverlappedCallback,
|
|
AUI_METHOD(void, OnSuccess, (AuSPtr<IOverlappedOperationBase>, pOriginator)),
|
|
AUI_METHOD(void, OnFailure, (AuSPtr<IOverlappedOperationBase>, pOriginator))
|
|
);
|
|
|
|
struct IOverlappedOperationBase
|
|
{
|
|
virtual AuSPtr<Loop::ILoopSource> ToWaitable() = 0;
|
|
|
|
virtual AuSPtr<IOverlappedCallback> SetCallback(AuSPtr<IOverlappedOperationBase> pCallback) = 0;
|
|
|
|
virtual bool IsOperationComplete() = 0;
|
|
virtual bool IsOperationSuccessful() = 0;
|
|
};
|
|
|
|
struct IOverlappedStatOperation : IOverlappedOperationBase
|
|
{
|
|
virtual AuSPtr<Stat> GetStats() = 0;
|
|
};
|
|
|
|
struct IOverlappedReadOperation : IOverlappedOperationBase
|
|
{
|
|
virtual AuSPtr<Aurora::Memory::ByteBuffer> GetByteBuffer() = 0;
|
|
virtual AuSPtr<Aurora::Memory::MemoryViewWrite> 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 occur 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<IOverlappedOperationBase> OverlappedCompress(const AuString &path, AuInt8 iLevel = 17);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedDecompress(const AuString &path);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedWrite(const AuString &path, AuSPtr<Aurora::Memory::MemoryViewRead> pMemoryView);
|
|
AUKN_SYM AuSPtr<IOverlappedReadOperation> OverlappedRead(const AuString &path);
|
|
AUKN_SYM AuSPtr<IOverlappedStatOperation> OverlappedStat(const AuString &path);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedCopy(const AuString &path, const AuString &dest);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedRelink(const AuString &path, const AuString &dest);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedTrustFile(const AuString &path);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedBlockFile(const AuString &path);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedUnblockFile(const AuString &path);
|
|
AUKN_SYM AuSPtr<IOverlappedOperationBase> OverlappedDelete(const AuString &path);
|
|
} |