Skip to content

Commit

Permalink
Remove all remaining mentions of async_file_handle (issue #78).
Browse files Browse the repository at this point in the history
  • Loading branch information
ned14 committed Apr 20, 2021
1 parent 6735fab commit 565f275
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 44 deletions.
25 changes: 0 additions & 25 deletions example/use_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,31 +307,6 @@ void sparse_array()
}
#endif

#if LLFIO_HAVE_COROUTINES
std::future<void> coroutine_write()
{
//! [coroutine_write]
namespace llfio = LLFIO_V2_NAMESPACE;

// Create an asynchronous file handle
llfio::io_service service;
llfio::async_file_handle fh =
llfio::async_file(service, {}, "testfile.txt",
llfio::async_file_handle::mode::write,
llfio::async_file_handle::creation::if_needed).value();

// Resize it to 1024 bytes
truncate(fh, 1024).value();

// Begin to asynchronously write "hello world" into the file at offset 0,
// suspending execution of this coroutine until completion and then resuming
// execution. Requires the Coroutines TS.
alignas(4096) char buffer[] = "hello world";
co_await co_write(fh, 0, { { reinterpret_cast<llfio::byte *>(buffer), sizeof(buffer) } }).value();
//! [coroutine_write]
}
#endif

int main()
{
return 0;
Expand Down
8 changes: 2 additions & 6 deletions include/llfio/v2.0/file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ Distributed under the Boost Software License, Version 1.0.
LLFIO_V2_NAMESPACE_EXPORT_BEGIN

/*! \class file_handle
\brief A handle to a regular file or device, kept data layout compatible with
async_file_handle.
\brief A handle to a regular file or device.
<table>
<tr><th></th><th>Cost of opening</th><th>Cost of i/o</th><th>Concurrency and Atomicity</th><th>Other remarks</th></tr>
<tr><td>`file_handle`</td><td>Least</td><td>Syscall</td><td>POSIX guarantees (usually)</td><td>Least gotcha</td></tr>
<tr><td>`async_file_handle`</td><td>More</td><td>Most (syscall + malloc/free + reactor)</td><td>POSIX guarantees (usually)</td><td>Makes no sense to use with
cached i/o as it's a very expensive way to call `memcpy()`</td></tr> <tr><td>`mapped_file_handle`</td><td>Most</td><td>Least</td><td>None</td><td>Cannot be used
<tr><td>`mapped_file_handle`</td><td>Most</td><td>Least</td><td>None</td><td>Cannot be used
with uncached i/o</td></tr>
</table>
Expand Down Expand Up @@ -379,7 +377,6 @@ class LLFIO_DECL file_handle : public lockable_io_handle, public fs_handle
handle configuration (e.g. writing to regular files on POSIX or writing to a non-overlapped
HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle may perform one calloc and one free.
*/
LLFIO_MAKE_FREE_FUNCTION
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> zero(extent_pair extent, deadline d = deadline()) noexcept;
Expand Down Expand Up @@ -529,7 +526,6 @@ Note function may return significantly after this deadline if the i/o takes long
returned if deadline i/o is not possible with this particular handle configuration (e.g.
writing to regular files on POSIX or writing to a non-overlapped HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle may perform one calloc and one free.
*/
inline result<file_handle::extent_type> zero(file_handle &self, file_handle::extent_type offset, file_handle::extent_type bytes,
deadline d = deadline()) noexcept
Expand Down
4 changes: 0 additions & 4 deletions include/llfio/v2.0/io_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ class LLFIO_DECL io_handle : public handle
returned if deadline i/o is not possible with this particular handle configuration (e.g.
reading from regular files on POSIX or reading from a non-overlapped HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle performs one calloc and one free.
*/
LLFIO_MAKE_FREE_FUNCTION
io_result<buffers_type> read(io_request<buffers_type> reqs, deadline d = deadline()) noexcept { return (_ctx == nullptr) ? _do_read(reqs, d) : _do_multiplexer_read({}, reqs, d); }
Expand Down Expand Up @@ -321,7 +320,6 @@ class LLFIO_DECL io_handle : public handle
returned if deadline i/o is not possible with this particular handle configuration (e.g.
writing to regular files on POSIX or writing to a non-overlapped HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle performs one calloc and one free.
*/
LLFIO_MAKE_FREE_FUNCTION
io_result<const_buffers_type> write(io_request<const_buffers_type> reqs, deadline d = deadline()) noexcept { return (_ctx == nullptr) ? _do_write(reqs, d) : _do_multiplexer_write({}, std::move(reqs), d); }
Expand Down Expand Up @@ -569,7 +567,6 @@ Note function may return significantly after this deadline if the i/o takes long
returned if deadline i/o is not possible with this particular handle configuration (e.g.
reading from regular files on POSIX or reading from a non-overlapped HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle performs one calloc and one free.
*/
inline io_handle::io_result<io_handle::buffers_type> read(io_handle &self, io_handle::io_request<io_handle::buffers_type> reqs, deadline d = deadline()) noexcept
{
Expand All @@ -595,7 +592,6 @@ Note function may return significantly after this deadline if the i/o takes long
returned if deadline i/o is not possible with this particular handle configuration (e.g.
writing to regular files on POSIX or writing to a non-overlapped HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle performs one calloc and one free.
*/
inline io_handle::io_result<io_handle::const_buffers_type> write(io_handle &self, io_handle::io_request<io_handle::const_buffers_type> reqs, deadline d = deadline()) noexcept
{
Expand Down
5 changes: 0 additions & 5 deletions include/llfio/v2.0/lockable_io_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class LLFIO_DECL lockable_io_handle : public io_handle
for a RAII locker.
\errors Any of the values POSIX `flock()` can return.
\mallocs The default synchronous implementation in `file_handle` performs no memory allocation.
The asynchronous implementation in `async_file_handle` performs one calloc and one free.
*/
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<void> lock_file() noexcept;
/*! \brief Tries to lock the inode referred to by the open handle for exclusive access,
Expand All @@ -115,7 +114,6 @@ class LLFIO_DECL lockable_io_handle : public io_handle
for a RAII locker.
\errors Any of the values POSIX `flock()` can return.
\mallocs The default synchronous implementation in `file_handle` performs no memory allocation.
The asynchronous implementation in `async_file_handle` performs one calloc and one free.
*/
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC bool try_lock_file() noexcept;
/*! \brief Unlocks a previously acquired exclusive lock.
Expand All @@ -128,7 +126,6 @@ class LLFIO_DECL lockable_io_handle : public io_handle
for a RAII locker.
\errors Any of the values POSIX `flock()` can return.
\mallocs The default synchronous implementation in `file_handle` performs no memory allocation.
The asynchronous implementation in `async_file_handle` performs one calloc and one free.
*/
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<void> lock_file_shared() noexcept;
/*! \brief Tries to lock the inode referred to by the open handle for shared access,
Expand All @@ -138,7 +135,6 @@ class LLFIO_DECL lockable_io_handle : public io_handle
for a RAII locker.
\errors Any of the values POSIX `flock()` can return.
\mallocs The default synchronous implementation in `file_handle` performs no memory allocation.
The asynchronous implementation in `async_file_handle` performs one calloc and one free.
*/
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC bool try_lock_file_shared() noexcept;
/*! \brief Unlocks a previously acquired shared lock.
Expand Down Expand Up @@ -268,7 +264,6 @@ class LLFIO_DECL lockable_io_handle : public io_handle
returned if deadline i/o is not possible with this particular handle configuration (e.g.
non-overlapped HANDLE on Windows).
\mallocs The default synchronous implementation in file_handle performs no memory allocation.
The asynchronous implementation in async_file_handle performs one calloc and one free.
*/
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_guard> lock_file_range(extent_type offset, extent_type bytes, lock_kind kind, deadline d = deadline()) noexcept;
//! \overload EXTENSION: Locks for shared access
Expand Down
3 changes: 1 addition & 2 deletions include/llfio/v2.0/mapped_file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ LLFIO_V2_NAMESPACE_EXPORT_BEGIN
<table>
<tr><th></th><th>Cost of opening</th><th>Cost of i/o</th><th>Concurrency and Atomicity</th><th>Other remarks</th></tr>
<tr><td>`file_handle`</td><td>Least</td><td>Syscall</td><td>POSIX guarantees (usually)</td><td>Least gotcha</td></tr>
<tr><td>`async_file_handle`</td><td>More</td><td>Most (syscall + malloc/free + reactor)</td><td>POSIX guarantees (usually)</td><td>Makes no sense to use with
cached i/o as it's a very expensive way to call `memcpy()`</td></tr> <tr><td>`mapped_file_handle`</td><td>Most</td><td>Least</td><td>None</td><td>Cannot be used
<tr><td>`mapped_file_handle`</td><td>Most</td><td>Least</td><td>None</td><td>Cannot be used
with uncached i/o</td></tr>
</table>
Expand Down
3 changes: 1 addition & 2 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Todo list for already implemented parts: https://ned14.github.io/llfio/todo.html
| ✔ | ✔ | Universal native handle/fd abstraction instead of `void *`.
| ✔ | ✔ | Perfectly/Ideally low memory (de)allocation per op (usually none).
| ✔ | ✔ | noexcept API throughout returning error_code for failure instead of throwing exceptions.
| ✔ | ✔ | LLFIO v1 handle type split into hierarchy of types:<ol><li>handle - provides open, close, get path, clone, set/unset append only, change caching, characteristics<li>fs_handle - handles with an inode number<li>path_handle - a race free anchor to a subset of the filesystem<li>directory_handle - enumerates the filesystem<li>io_handle - adds synchronous scatter-gather i/o, byte range locking<li>file_handle - adds open/create file, get and set maximum extent<li>async_file_handle - adds asynchronous scatter-gather i/o<li>mapped_file_handle - adds low latency memory mapped scatter-gather i/o</ol>
| ✔ | ✔ | LLFIO v1 handle type split into hierarchy of types:<ol><li>handle - provides open, close, get path, clone, set/unset append only, change caching, characteristics<li>fs_handle - handles with an inode number<li>path_handle - a race free anchor to a subset of the filesystem<li>directory_handle - enumerates the filesystem<li>io_handle - adds synchronous scatter-gather i/o, byte range locking<li>file_handle - adds open/create file, get and set maximum extent<li>mapped_file_handle - adds low latency memory mapped scatter-gather i/o</ol>
| ✔ | ✔ | Cancelable i/o (made possible thanks to dropping XP support).
| ✔ | ✔ | All shared_ptr usage removed as all use of multiple threads removed.
| ✔ | ✔ | Use of std::vector to transport scatter-gather sequences replaced with C++ 20 `span<>` borrowed views.
Expand Down Expand Up @@ -125,7 +125,6 @@ Todo:
| | ✔ | ✔ | Directory handles and very fast directory enumeration ported over from LLFIO v1.
| ✔ | ✔ | ✔ | `shared_fs_mutex` shared/exclusive entities locking based on safe byte ranges
| | ✔ | ✔ | Set random or sequential i/o (prefetch).
| ✔ | ✔ | ✔ | i/o on `async_file_handle` is coroutines awaitable.
| ✔ | ✔ | ✔ | `llfio::algorithm::trivial_vector<T>` with constant time reallocation if `T` is trivially copyable.
| | ✔ | ✔ | `symlink_handle`.
| ✔ | ✔ | ✔ | Large, huge and massive page size support for memory allocation and (POSIX only) file maps.
Expand Down

0 comments on commit 565f275

Please sign in to comment.