NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::file_async类 参考

文件异步I/O管理类 更多...

#include <file_async.hpp>

Public 类型

using size_type = ::DWORD
 大小类型
using difference_type = ::LONGLONG
 偏移量类型
using native_handle_type = _NEFORCE native_handle_type
 原生文件句柄类型

Public 成员函数

 file_async (native_handle_type handle)
 构造函数
 ~file_async ()
 析构函数
 file_async (file_async &&other) noexcept
 移动构造函数
file_asyncoperator= (file_async &&other) noexcept
 移动赋值运算符
void async_read (io_context &ctx, string &buffer, size_type size, function< void(error_code, size_type)> handler)
 异步读取数据
void async_read (io_context &ctx, string &buffer, size_type size, difference_type offset, function< void(error_code, size_type)> handler)
 指定偏移量异步读取数据
void async_read (io_context &ctx, string &buffer, size_type size, cancellation_slot &slot, function< void(error_code, size_type)> handler)
 带取消槽异步读取数据
void async_write (io_context &ctx, string data, size_type size, function< void(error_code, size_type)> handler)
 异步写入数据
void async_write (io_context &ctx, string data, size_type size, difference_type offset, function< void(error_code, size_type)> handler)
 指定偏移量异步写入数据
void async_write (io_context &ctx, string data, size_type size, cancellation_slot &slot, function< void(error_code, size_type)> handler)
 带取消槽异步写入数据
native_handle_type native_handle () const noexcept
 获取原生文件句柄

详细描述

文件异步I/O管理类

提供对文件句柄的异步读写操作,由 io_context 事件循环驱动。 handler 在 io_context::run() 线程中执行。

注解
不持有文件句柄所有权,句柄生命周期由调用方保证。

在文件 file_async.hpp34 行定义.

构造及析构函数说明

◆ file_async() [1/2]

neforce::file_async::file_async ( native_handle_type handle)
explicit

构造函数

参数
handle已打开的文件句柄

被这些函数引用 file_async(), operator=() , 以及 ~file_async().

◆ file_async() [2/2]

neforce::file_async::file_async ( file_async && other)
noexcept

移动构造函数

参数
other要移动的对象

引用了 file_async().

成员函数说明

◆ async_read() [1/3]

void neforce::file_async::async_read ( io_context & ctx,
string & buffer,
size_type size,
cancellation_slot & slot,
function< void(error_code, size_type)> handler )
inline

带取消槽异步读取数据

参数
ctx异步 I/O 执行上下文
buffer输出缓冲区
size要读取的字节数
slot取消槽
handler完成回调 void(error_code, size_type bytes_read)

在文件 file_async.hpp122 行定义.

引用了 neforce::move() , 以及 neforce::size().

◆ async_read() [2/3]

void neforce::file_async::async_read ( io_context & ctx,
string & buffer,
size_type size,
difference_type offset,
function< void(error_code, size_type)> handler )
inline

指定偏移量异步读取数据

参数
ctx异步 I/O 执行上下文
buffer输出缓冲区
size要读取的字节数
offset文件偏移量,-1 使用当前位置
handler完成回调 void(error_code, size_type bytes_read)

在文件 file_async.hpp109 行定义.

引用了 neforce::move() , 以及 neforce::size().

◆ async_read() [3/3]

void neforce::file_async::async_read ( io_context & ctx,
string & buffer,
size_type size,
function< void(error_code, size_type)> handler )
inline

异步读取数据

参数
ctx异步 I/O 执行上下文
buffer输出缓冲区
size要读取的字节数
handler完成回调 void(error_code, size_type bytes_read)

在文件 file_async.hpp97 行定义.

引用了 neforce::move() , 以及 neforce::size().

◆ async_write() [1/3]

void neforce::file_async::async_write ( io_context & ctx,
string data,
size_type size,
cancellation_slot & slot,
function< void(error_code, size_type)> handler )
inline

带取消槽异步写入数据

参数
ctx异步 I/O 执行上下文
data要写入的数据
size要写入的字节数
slot取消槽
handler完成回调 void(error_code, size_type bytes_written)

在文件 file_async.hpp161 行定义.

引用了 neforce::data(), neforce::move() , 以及 neforce::size().

◆ async_write() [2/3]

void neforce::file_async::async_write ( io_context & ctx,
string data,
size_type size,
difference_type offset,
function< void(error_code, size_type)> handler )
inline

指定偏移量异步写入数据

参数
ctx异步 I/O 执行上下文
data要写入的数据
size要写入的字节数
offset文件偏移量,-1 使用当前位置
handler完成回调 void(error_code, size_type bytes_written)

在文件 file_async.hpp148 行定义.

引用了 neforce::data(), neforce::move() , 以及 neforce::size().

◆ async_write() [3/3]

void neforce::file_async::async_write ( io_context & ctx,
string data,
size_type size,
function< void(error_code, size_type)> handler )
inline

异步写入数据

参数
ctx异步 I/O 执行上下文
data要写入的数据
size要写入的字节数
handler完成回调 void(error_code, size_type bytes_written)

数据被内部拷贝,调用者可以立即释放。

在文件 file_async.hpp136 行定义.

引用了 neforce::data(), neforce::move() , 以及 neforce::size().

◆ native_handle()

native_handle_type neforce::file_async::native_handle ( ) const
inlinenodiscardnoexcept

获取原生文件句柄

返回
原生文件句柄

在文件 file_async.hpp170 行定义.

◆ operator=()

file_async & neforce::file_async::operator= ( file_async && other)
noexcept

移动赋值运算符

参数
other要移动的对象
返回
自身引用

引用了 file_async().


该类的文档由以下文件生成: