AuroraRuntime/Include/Aurora/IO/FS/Async.hpp
2021-09-13 21:11:12 +01:00

43 lines
1.1 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AFIO.hpp
Date: 2021-8-21
Author: Reece
***/
#pragma once
namespace Aurora::IO::FS
{
class IAsyncTransaction;
class IAsyncFileStream
{
public:
virtual AuSPtr<IAsyncTransaction> NewTransaction() = 0;
};
class IAsyncFinishedSubscriber
{
public:
virtual void OnAsyncFileOpFinished(AuUInt64 offset, AuUInt32 length) = 0;
};
class IAsyncTransaction
{
public:
virtual bool StartRead(AuUInt64 offset, void *, AuUInt32 length) = 0;
virtual bool StartWrite(AuUInt64 offset, const void *, AuUInt32 length) = 0;
virtual bool Complete() = 0;
virtual AuUInt32 GetLastPacketLength() = 0;
virtual void SetCallback(const AuSPtr<IAsyncFinishedSubscriber> &sub) = 0;
virtual void Wait(AuUInt32 timeout) = 0;
};
AUKN_SHARED_API(OpenAsync, IAsyncFileStream, const AuString &path, bool readOnly = true, bool directIO = false);
AUKN_SYM bool WaitMultiple(const AuList<IAsyncTransaction> &files, AuUInt32 timeout);
}