boost::corosio::native_random_access_file
A random‐access file with devirtualized async I/O operations.
Synopsis
Declared in <boost/corosio/native/native_random_access_file.hpp>
template<auto Backend>
class native_random_access_file
: public random_access_file
Description
This class template inherits from random_access_file and shadows read_some_at / write_some_at with versions that call the backend implementation directly, allowing the compiler to inline through the entire call chain.
Non‐async operations (open, close, size, resize, sync_data, sync_all) remain unchanged and dispatch through the compiled library.
A native_random_access_file IS‐A random_access_file and can be passed to any function expecting random_access_file&, in which case virtual dispatch is used transparently.
|
On POSIX platforms, file I/O is dispatched to a thread pool regardless of the chosen reactor backend, so all three reactor tags ( |
Thread Safety
Same as random_access_file.
Example
#include <boost/corosio/native/native_random_access_file.hpp>
native_io_context<epoll> ctx;
native_random_access_file<epoll> f(ctx);
f.open("data.bin", file_base::read_only);
char buf[4096];
auto [ec, n] = co_await f.read_some_at(
0, capy::mutable_buffer(buf, sizeof(buf)));
Base Classes
Name |
Description |
An asynchronous random‐access file for coroutine I/O. |
Types
Name |
Description |
RAII wrapper for I/O object implementation lifetime. |
|
Platform‐specific random‐access file implementation interface. |
|
Service interface for I/O object lifecycle management. |
|
Awaitable for async read‐at operations. |
|
Awaitable for async write‐at operations. |
Member Functions
Name |
Description |
|
Constructors |
|
Assignment operators |
Adopt an existing native handle. |
|
Cancel pending asynchronous operations. |
|
Close the file. |
|
Return the execution context. |
|
Check if the file is open. |
|
Get the native file descriptor or handle. |
|
Open a file. |
|
Asynchronously read at the given offset. |
|
Release ownership of the native handle. |
|
Resize the file. |
|
Return the file size in bytes. |
|
Synchronize file data and metadata to stable storage. |
|
Synchronize file data to stable storage. |
|
Asynchronously write at the given offset. |
Protected Member Functions
Name |
Description |
|
Move assign from another I/O object. |
Protected Static Member Functions
Name |
Description |
Create a handle bound to a service found in the context. |
Template Parameters
Name |
Description |
Backend |
A backend tag value (e.g., |
See Also
random_access_file, epoll_t, iocp_t
Created with MrDocs