AuroraRuntime/Source/IO/FS/Async.NT.hpp

91 lines
2.5 KiB
C++
Raw Normal View History

/***
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<IAsyncTransaction> NewTransaction() override;
bool BlockingTruncate(AuUInt64 length) override;
bool BlockingRead(AuUInt64 offset, const Memory::MemoryViewStreamWrite &parameters) override;
bool BlockingWrite(AuUInt64 offset, const Memory::MemoryViewStreamRead &parameters) override;
2023-07-29 07:02:47 +00:00
void Init(const AuSPtr<IIOHandle> &pHandle);
2023-07-29 07:02:47 +00:00
AuSPtr<IIOHandle> GetHandle();
private:
2023-07-29 07:02:47 +00:00
AuSPtr<IIOHandle> pHandle_;
};
struct NtAsyncFileTransaction : IAsyncTransaction, AuEnableSharedFromThis<NtAsyncFileTransaction>
{
~NtAsyncFileTransaction();
2023-07-29 07:02:47 +00:00
bool Init(const AuSPtr<IIOHandle> &handle);
bool InitWeak(const AuSPtr<IIOHandle> &handle);
void ResetAIO();
bool StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView) override;
bool StartWrite(AuUInt64 offset, const AuSPtr<AuMemoryViewRead> &memoryView) override;
bool isIrredeemable_ {};
2023-08-08 23:14:36 +00:00
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<IAsyncFinishedSubscriber> &sub) override;
2023-08-08 23:02:35 +00:00
void SetBaseOffset(AuUInt64 uBaseOffset) override;
bool Wait(AuUInt32 timeout) override;
AuSPtr<AuLoop::ILoopSource> NewLoopSource() override;
void Reset();
bool IDontWannaUsePorts();
void DispatchCb(AuUInt32 len);
HANDLE GetHandle();
2023-07-29 07:02:47 +00:00
AuSPtr<IIOHandle> GetFileHandle();
OVERLAPPED overlap {};
HANDLE event = INVALID_HANDLE_VALUE;
AuSPtr<NtAsyncFileTransaction> pPin;
2023-08-08 23:02:35 +00:00
AuUInt32 dwLastAbstractStat {};
AuUInt64 qwLastAbstractOffset {};
bool bLatch {};
AuUInt32 dwLastBytes {};
AuUInt32 dwOsErrorCode {};
bool bHasFailed {};
2023-08-08 23:02:35 +00:00
AuUInt64 uBaseOffset {};
AuWPtr<Aurora::IO::IPC::IPCPipeImpl> pNtIpcPipeImpl;
AuSPtr<void> pMemoryHold;
private:
2023-07-29 07:02:47 +00:00
AuSPtr<IIOHandle> pHandle_;
AuWPtr<IIOHandle> wpHandle_;
AuSPtr<IAsyncFinishedSubscriber> pSub_;
};
}