AuroraRuntime/Include/Aurora/IO/FS/Async.hpp

39 lines
1.4 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
{
// WARNING: ASYNC FILE IS SINGLE THREAD ONLY.
// THESE APIS ARE NOT YET MT SAFE
// LOOP SOURCES ARE THE ONLY EXCEPTION
AUKN_SHARED_API(OpenAsync, IAsyncFileStream, const AuString &path, EFileOpenMode openMode, bool directIO = false, EFileAdvisoryLockLevel lock = EFileAdvisoryLockLevel::eNoSafety);
/**
* Waits for at least one file IO event
* @param transactions An array mask of FIO transactions
* @param timeout Timeout in milliseconds, zero = indefinite
*/
AUKN_SYM AuUInt32 WaitMultiple(const AuList<AuSPtr<IAsyncTransaction>> &transactions, AuUInt32 timeout);
/**
* A hint to dispatch any outstanding IO requests.
*
* The Aurora Runtime optimizes file FileRead/Writes by batching on some platforms.
* It may be required to call SendBatched for lower latency immediately after a Read/Write.
*
* Consider any call to WaitMultiple, internal loop source signal state, or loop queue wait,
* an internal hint to request an async IO work-queue flush.
*
* @warning This does nothing on NT
* @warning Linux StartRead/StartWrites will not start immediately. They instead wait for a yield or call to SendBatched.
*/
AUKN_SYM void SendBatched();
}