1#ifndef NEFORCE_CORE_FILE_FILE_ASYNC_HPP__
2#define NEFORCE_CORE_FILE_FILE_ASYNC_HPP__
14#include "NeForce/core/exception/error_code.hpp"
17#ifdef NEFORCE_PLATFORM_LINUX
20NEFORCE_BEGIN_NAMESPACE__
43#ifdef NEFORCE_PLATFORM_WINDOWS
60 struct async_context {
62 string* buffer =
nullptr;
64 bool is_write =
false;
70 explicit async_context(
string d);
76 explicit async_context(
string* buf);
101 mutable mutex mutex_;
187NEFORCE_END_NAMESPACE__
::aiocb aiocb_type
异步I/O控制块类型
async_result write(string data, size_type size, difference_type offset=-1)
提交异步写入操作
void cancel(async_result &result) noexcept
取消异步操作
bool wait(async_result &result, uint32_t timeout_ms=numeric_traits< uint32_t >::max())
等待异步操作完成
file_async(file_async &&other) noexcept
移动构造函数
_NEFORCE native_handle_type native_handle_type
原生文件句柄类型
async_result read(string &buffer, size_type size, difference_type offset=-1) const
提交异步读取操作
file_async(native_handle_type handle)
构造函数
file_async & operator=(file_async &&other) noexcept
移动赋值运算符
::off_t difference_type
偏移量类型
static NEFORCE_NODISCARD constexpr T max() noexcept
获取类型的最大值
unsigned int uint32_t
32位无符号整数类型
@ OVERLAPPED
Linux不支持异步I/O标志
NEFORCE_ALWAYS_INLINE_INLINE thread::native_handle_type handle() noexcept
获取当前线程句柄
NEFORCE_NODISCARD NEFORCE_ALWAYS_INLINE constexpr decltype(auto) size(const Container &cont) noexcept(noexcept(cont.size()))
获取容器的大小
NEFORCE_NODISCARD NEFORCE_ALWAYS_INLINE constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针
size_t bytes_transferred
实际传输的字节数
aiocb_type * cb
异步I/O控制块指针
async_context * user_context
用户上下文指针