/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Async.NT.hpp Date: 2021-9-13 Author: Reece ***/ #pragma once namespace Aurora::IO::IPC { struct IPCPipeImpl; } namespace Aurora::IO::FS { struct NtAsyncFileStream : IAsyncFileStream { AuSPtr NewTransaction() override; bool BlockingTruncate(AuUInt64 length) override; bool BlockingRead(AuUInt64 offset, const Memory::MemoryViewStreamWrite ¶meters) override; bool BlockingWrite(AuUInt64 offset, const Memory::MemoryViewStreamRead ¶meters) override; void Init(const AuSPtr &pHandle); AuSPtr GetHandle(); private: AuSPtr pHandle_; }; struct NtAsyncFileTransaction : IAsyncTransaction, AuEnableSharedFromThis { ~NtAsyncFileTransaction(); bool Init(const AuSPtr &handle); bool InitWeak(const AuSPtr &handle); void ResetAIO(); bool StartRead(AuUInt64 offset, const AuSPtr &memoryView) override; bool StartWrite(AuUInt64 offset, const AuSPtr &memoryView) override; bool isIrredeemable_ {}; bool HasCompleted() override; bool Complete() override; bool CompleteEx(AuUInt completeRoutine, bool bForce = false); bool Failed() override; AuUInt GetOSErrorCode() override; AuUInt32 GetLastPacketLength() override; void SetCallback(const AuSPtr &sub) override; void SetBaseOffset(AuUInt64 uBaseOffset) override; bool Wait(AuUInt32 timeout) override; AuSPtr NewLoopSource() override; void Reset(); bool IDontWannaUsePorts(); void DispatchCb(AuUInt32 len); HANDLE GetHandle(); AuSPtr GetFileHandle(); OVERLAPPED overlap {}; HANDLE event = INVALID_HANDLE_VALUE; AuSPtr pPin; AuUInt32 dwLastAbstractStat {}; AuUInt64 qwLastAbstractOffset {}; bool bLatch {}; AuUInt32 dwLastBytes {}; AuUInt32 dwOsErrorCode {}; bool bHasFailed {}; AuUInt64 uBaseOffset {}; AuWPtr pNtIpcPipeImpl; AuSPtr pMemoryHold; private: AuSPtr pHandle_; AuWPtr wpHandle_; AuSPtr pSub_; }; }