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

86 lines
2.4 KiB
C++

/***
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;
void Init(const AuSPtr<IIOHandle> &pHandle);
AuSPtr<IIOHandle> GetHandle();
private:
AuSPtr<IIOHandle> pHandle_;
};
struct NtAsyncFileTransaction : IAsyncTransaction, AuEnableSharedFromThis<NtAsyncFileTransaction>
{
~NtAsyncFileTransaction();
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_ {};
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;
bool Wait(AuUInt32 timeout) override;
AuSPtr<AuLoop::ILoopSource> NewLoopSource() override;
void Reset();
bool IDontWannaUsePorts();
void DispatchCb(AuUInt32 len);
HANDLE GetHandle();
AuSPtr<IIOHandle> GetFileHandle();
OVERLAPPED overlap {};
HANDLE event = INVALID_HANDLE_VALUE;
AuSPtr<NtAsyncFileTransaction> pPin;
AuUInt32 dwLastAbstractStat {},
dwLastAbstractOffset {};
bool bLatch {};
AuUInt32 dwLastBytes {};
AuUInt32 dwOsErrorCode {};
bool bHasFailed {};
AuWPtr<Aurora::IO::IPC::IPCPipeImpl> pNtIpcPipeImpl;
AuSPtr<void> pMemoryHold;
private:
AuSPtr<IIOHandle> pHandle_;
AuWPtr<IIOHandle> wpHandle_;
AuSPtr<IAsyncFinishedSubscriber> pSub_;
};
}