AuroraRuntime/Include/Aurora/IO/Adapters/IOAdapterAsyncStream.hpp

50 lines
1.5 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IOAdapterAsyncStream.hpp
Date: 2022-6-6
Author: Reece
***/
#pragma once
namespace Aurora::IO::Adapters
{
struct IAsyncStreamReader : IStreamReader
{
/**
* @brief Optional advanced use case.
* Begins work given caller provided memory
* @return
*/
virtual EStreamError BeginRead(const AuSPtr<Memory::MemoryViewWrite> &internalView) = 0;
/**
* @brief Optional advanced use case.
* Dequeues work done by begin read
* @return
*/
virtual EStreamError Dequeue(AuUInt reqLength, Memory::MemoryViewWrite &out) = 0;
};
struct IAsyncStreamAdapter
{
virtual bool SetFlushOnWrite(bool value) = 0;
virtual void ReserveBuffer(AuUInt64 length) = 0;
virtual AuUInt64 GetReadOffset() = 0;
virtual AuUInt64 SetReadOffset(AuUInt64 offset) = 0;
virtual AuUInt64 GetWriteOffset() = 0;
virtual AuUInt64 SetWriteOffset(AuUInt64 offset) = 0;
virtual AuSPtr<IAsyncStreamReader> ToStreamReader() = 0;
virtual AuSPtr<IStreamWriter> ToStreamWriter() = 0;
virtual AuSPtr<IIOWaitableItem> ToWaitable() = 0;
virtual bool Reset() = 0;
};
AUKN_SYM AuSPtr<IAsyncStreamAdapter> NewAsyncStreamAdapter(const AuSPtr<IAsyncTransaction> &pTransaction, bool bIsStream);
}