eve.rt.fiber.file
Fiber-File — Blocking-Style File I/O on Top of Eve's AsyncFile
This module provides FiberFile, a struct wrapper around Eve's callback-driven AsyncFile that turns every I/O operation into a fiber yield point. From the caller's perspective the API looks blocking; from the event loop's perspective it is just more callbacks.
Must be used from within a fiber that is managed by a FiberScheduler attached to an EventLoop.
Example (inside a fiber):
auto f = FiberFile.create(sched, loop);
scope (exit) f.dispose();
f.open("/etc/hostname", O_RDONLY);
auto content = f.read(0, 4096);
f.close();Copyright
Types 1
A fiber-friendly async file handle.
Wraps an AsyncFile. Read and write operations yield the current fiber and resume when the operation completes or fails.
Concurrency: AsyncFile supports at most one pending operation at a time. Do not call read() or write() concurrently from multiple fibers on the same FiberFile.
Open is synchronous: open() calls the OS open() syscall directly and does not yield the fiber. Only read() and write() yield.
FiberFile create(FiberScheduler sched, ref EventLoop loop) static @trustedCreate a `FiberFile` bound to the given scheduler and event loop.OpenResult open(scope const(char)[] path, int flags) @trustedOpen a file. Synchronous — does not yield the fiber.ubyte[] read(ulong offset, size_t maxBytes = 4096) @trustedRead up to `maxBytes` starting at `offset`. Yields until the read completes.size_t readInto(ubyte[] buffer, ulong offset) @trustedRead into a caller-supplied buffer starting at `offset`. Yields until the read completes.size_t write(scope const(ubyte)[] data, ulong offset) @trustedWrite data at the given offset. Yields until the write completes.bool usingIoUring() @property const @safe nothrow @nogcCheck whether the file is using io_uring (Linux only).