2021-09-14 13:13:58 +00:00
|
|
|
/***
|
|
|
|
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
|
|
|
|
|
2022-06-22 20:24:04 +00:00
|
|
|
namespace Aurora::IO::IPC
|
|
|
|
{
|
|
|
|
struct IPCPipeImpl;
|
|
|
|
}
|
|
|
|
|
2021-09-14 13:13:58 +00:00
|
|
|
namespace Aurora::IO::FS
|
|
|
|
{
|
2022-04-17 12:40:08 +00:00
|
|
|
struct NtAsyncFileStream : IAsyncFileStream
|
|
|
|
{
|
|
|
|
AuSPtr<IAsyncTransaction> 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;
|
|
|
|
|
2023-07-29 07:02:47 +00:00
|
|
|
void Init(const AuSPtr<IIOHandle> &pHandle);
|
2022-04-17 12:40:08 +00:00
|
|
|
|
2023-07-29 07:02:47 +00:00
|
|
|
AuSPtr<IIOHandle> GetHandle();
|
2022-04-17 12:40:08 +00:00
|
|
|
|
|
|
|
private:
|
2023-07-29 07:02:47 +00:00
|
|
|
AuSPtr<IIOHandle> pHandle_;
|
2022-04-17 12:40:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
2023-04-26 06:24:17 +00:00
|
|
|
void ResetAIO();
|
2022-04-17 12:40:08 +00:00
|
|
|
|
|
|
|
bool StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView) override;
|
|
|
|
bool StartWrite(AuUInt64 offset, const AuSPtr<AuMemoryViewRead> &memoryView) override;
|
|
|
|
|
2022-06-24 19:33:55 +00:00
|
|
|
bool isIrredeemable_ {};
|
|
|
|
|
2023-08-08 23:14:36 +00:00
|
|
|
bool HasCompleted() override;
|
|
|
|
|
2022-06-11 23:01:27 +00:00
|
|
|
bool Complete() override;
|
|
|
|
|
2023-05-11 15:05:00 +00:00
|
|
|
bool CompleteEx(AuUInt completeRoutine, bool bForce = false);
|
2022-06-22 20:24:04 +00:00
|
|
|
|
2022-06-11 23:01:27 +00:00
|
|
|
bool Failed() override;
|
|
|
|
AuUInt GetOSErrorCode() override;
|
|
|
|
|
2022-04-17 12:40:08 +00:00
|
|
|
AuUInt32 GetLastPacketLength() override;
|
|
|
|
|
|
|
|
void SetCallback(const AuSPtr<IAsyncFinishedSubscriber> &sub) override;
|
|
|
|
|
2023-08-08 23:02:35 +00:00
|
|
|
void SetBaseOffset(AuUInt64 uBaseOffset) override;
|
|
|
|
|
2022-04-17 12:40:08 +00:00
|
|
|
bool Wait(AuUInt32 timeout) override;
|
2022-06-11 23:52:46 +00:00
|
|
|
AuSPtr<AuLoop::ILoopSource> NewLoopSource() override;
|
2022-04-17 12:40:08 +00:00
|
|
|
|
2022-05-05 10:24:44 +00:00
|
|
|
void Reset();
|
|
|
|
|
|
|
|
bool IDontWannaUsePorts();
|
|
|
|
|
2022-04-17 12:40:08 +00:00
|
|
|
void DispatchCb(AuUInt32 len);
|
|
|
|
HANDLE GetHandle();
|
2023-07-29 07:02:47 +00:00
|
|
|
AuSPtr<IIOHandle> GetFileHandle();
|
2022-04-17 12:40:08 +00:00
|
|
|
|
2022-08-18 16:19:32 +00:00
|
|
|
OVERLAPPED overlap {};
|
|
|
|
HANDLE event = INVALID_HANDLE_VALUE;
|
|
|
|
AuSPtr<NtAsyncFileTransaction> pPin;
|
2023-08-08 23:02:35 +00:00
|
|
|
AuUInt32 dwLastAbstractStat {};
|
|
|
|
AuUInt64 qwLastAbstractOffset {};
|
2022-08-18 16:19:32 +00:00
|
|
|
bool bLatch {};
|
|
|
|
AuUInt32 dwLastBytes {};
|
|
|
|
AuUInt32 dwOsErrorCode {};
|
|
|
|
bool bHasFailed {};
|
2023-08-08 23:02:35 +00:00
|
|
|
AuUInt64 uBaseOffset {};
|
2022-06-11 23:01:27 +00:00
|
|
|
|
2022-08-18 16:19:32 +00:00
|
|
|
AuWPtr<Aurora::IO::IPC::IPCPipeImpl> pNtIpcPipeImpl;
|
|
|
|
AuSPtr<void> pMemoryHold;
|
2022-06-22 20:24:04 +00:00
|
|
|
|
2022-07-05 03:17:28 +00:00
|
|
|
private:
|
2023-07-29 07:02:47 +00:00
|
|
|
AuSPtr<IIOHandle> pHandle_;
|
|
|
|
AuWPtr<IIOHandle> wpHandle_;
|
2022-08-18 16:19:32 +00:00
|
|
|
AuSPtr<IAsyncFinishedSubscriber> pSub_;
|
2022-04-17 12:40:08 +00:00
|
|
|
};
|
2021-09-14 13:13:58 +00:00
|
|
|
}
|