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

80 lines
2.3 KiB
C++
Raw Normal View History

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Async.Linux.hpp
Date: 2022-4-12
Author: Reece
***/
#pragma once
namespace Aurora::IO::IPC
{
struct IPCPipeImpl;
}
namespace Aurora::IO::FS
{
struct LinuxAsyncFileTransaction;
2022-06-12 13:53:35 +00:00
struct LinuxAsyncFileTransactionLoopSource;
struct LinuxAsyncFileStream : 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> &handle);
AuSPtr<IIOHandle> GetHandle();
private:
AuSPtr<IIOHandle> pHandle_;
};
struct LinuxAsyncFileTransaction : IAsyncTransaction, AuEnableSharedFromThis<LinuxAsyncFileTransaction>, Aurora::IO::UNIX::ASubmittable
{
~LinuxAsyncFileTransaction();
bool Init(const AuSPtr<IIOHandle> &handle);
bool StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView) override;
bool StartWrite(AuUInt64 offset, const AuSPtr<AuMemoryViewRead> &memoryView) override;
2023-08-08 23:14:36 +00:00
bool Complete() override;
2022-06-12 13:53:35 +00:00
bool Failed() override;
AuUInt GetOSErrorCode() override;
2023-08-08 23:14:36 +00:00
bool HasCompleted() override;
AuUInt32 GetLastPacketLength() override;
void SetCallback(const AuSPtr<IAsyncFinishedSubscriber> &sub) override;
bool Wait(AuUInt32 timeout) override;
AuSPtr<AuLoop::ILoopSource> NewLoopSource() override;
void Reset() override;
void DispatchCb();
AuSPtr<IIOHandle> GetFileHandle();
2023-08-08 23:02:35 +00:00
void SetBaseOffset(AuUInt64 uBaseOffset) override;
virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override;
private:
AuSPtr<IIOHandle> pHandle_;
2023-08-08 23:02:35 +00:00
AuUInt64 lastAbstractOffset_ {};
AuUInt32 lastFinishedStat_ {};
AuUInt64 uBaseOffset {};
bool latch_ {};
bool bTxFinished_ {};
AuSPtr<IAsyncFinishedSubscriber> sub_;
AuSPtr<LinuxAsyncFileTransactionLoopSource> loopSource_;
2022-06-12 13:53:35 +00:00
int error_ {};
bool hasError_ {};
};
}