Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-04-14 19:37:19 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-04-14 19:37:19 +0300
commitbb5b4123ccd90798ae4957a611c3725f5239ebd4 (patch)
tree6f8b8ef511197e8a78263d45467b9adbd8db62d6
parent4e837be97c2972e11a8515ae260e4476bd6654e3 (diff)
Rename file_handle::length() to maximum_extent()
Added example use case of reading all valid extents
-rw-r--r--example/use_cases.cpp92
-rw-r--r--include/afio/revision.hpp6
-rw-r--r--include/afio/v2.0/algorithm/mapped_span.hpp4
-rw-r--r--include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp2
-rw-r--r--include/afio/v2.0/detail/impl/posix/file_handle.ipp4
-rw-r--r--include/afio/v2.0/detail/impl/posix/mapped_file_handle.ipp4
-rw-r--r--include/afio/v2.0/detail/impl/storage_profile.ipp4
-rw-r--r--include/afio/v2.0/detail/impl/windows/file_handle.ipp2
-rw-r--r--include/afio/v2.0/detail/impl/windows/map_handle.ipp2
-rw-r--r--include/afio/v2.0/detail/impl/windows/mapped_file_handle.ipp4
-rw-r--r--include/afio/v2.0/file_handle.hpp15
-rw-r--r--include/afio/v2.0/map_handle.hpp14
-rw-r--r--include/afio/v2.0/mapped_file_handle.hpp10
m---------include/afio/v2.0/outcome0
-rw-r--r--test/tests/map_handle_create_close/runner.cpp2
-rw-r--r--test/tests/mapped_span.cpp6
16 files changed, 131 insertions, 40 deletions
diff --git a/example/use_cases.cpp b/example/use_cases.cpp
index c3b7ab0e..9cf22891 100644
--- a/example/use_cases.cpp
+++ b/example/use_cases.cpp
@@ -47,8 +47,8 @@ void read_entire_file1()
// default flags is none
).value(); // If failed, throw a filesystem_error exception
- // Make a vector sized the current length of the file
- std::vector<afio::byte> buffer(fh.length().value());
+ // Make a vector sized the current maximum extent of the file
+ std::vector<afio::byte> buffer(fh.maximum_extent().value());
// Synchronous scatter read from file
afio::file_handle::buffers_type filled = afio::read(
@@ -64,6 +64,92 @@ void read_entire_file1()
//! [file_entire_file1]
}
+void read_entire_file2()
+{
+ //! [file_entire_file2]
+ namespace afio = AFIO_V2_NAMESPACE;
+
+ // Create an i/o service to complete the async file i/o
+ afio::io_service service;
+
+ // Open the file for read
+ afio::async_file_handle fh = afio::async_file( //
+ service, // The i/o service to complete i/o to
+ {}, // path_handle to base directory
+ "foo" // path_view to path fragment relative to base directory
+ // default mode is read only
+ // default creation is open existing
+ // default caching is all
+ // default flags is none
+ ).value(); // If failed, throw a filesystem_error exception
+
+ // Get the valid extents of the file.
+ const std::vector<
+ std::pair<afio::file_handle::extent_type, afio::file_handle::extent_type>
+ > valid_extents = fh.extents().value();
+
+ // Schedule asynchronous reads for every valid extent
+ std::vector<std::pair<std::vector<afio::byte>, afio::async_file_handle::io_state_ptr>> buffers(valid_extents.size());
+ for (size_t n = 0; n < valid_extents.size(); n++)
+ {
+ // Set up the scatter buffer
+ buffers[n].first.resize(valid_extents[n].second);
+ for(;;)
+ {
+ afio::async_file_handle::buffer_type scatter_req{ buffers[n].first.data(), buffers[n].first.size() }; // buffer to fill
+ auto ret = afio::async_read( //
+ fh, // handle to read from
+ { { scatter_req } , 0 }, // The scatter request buffers
+ []( // The completion handler
+ afio::async_file_handle *, // The parent handle
+ afio::async_file_handle::io_result<afio::async_file_handle::buffers_type> & // Result of the i/o
+ ) { /* do nothing */ }
+ // default deadline is infinite
+ );
+ // Was the operation successful?
+ if (ret)
+ {
+ // Retain the handle to the outstanding i/o
+ buffers[n].second = std::move(ret).value();
+ break;
+ }
+ if (ret.error() == std::errc::resource_unavailable_try_again)
+ {
+ // Many async file i/o implementations have limited total system concurrency
+ std::this_thread::yield();
+ continue;
+ }
+ // Otherwise, throw a filesystem_error exception
+ ret.value();
+ }
+ }
+
+ // Pump i/o completion until no work remains
+ while (service.run().value())
+ {
+ // run() returns per completion handler dispatched if work remains
+ // It blocks until some i/o completes (there is a polling and deadline based overload)
+ // If no work remains, it returns false
+ }
+
+ // Gather the completions of all i/o scheduled for success and errors
+ for (auto &i : buffers)
+ {
+ // Did the read succeed?
+ if (i.second->result.read)
+ {
+ // Then adjust the buffer size to that actually read
+ i.first.resize(i.second->result.read.value().size());
+ }
+ else
+ {
+ // Throw the cause of failure as an exception
+ i.second->result.read.value();
+ }
+ }
+ //! [file_entire_file2]
+}
+
void scatter_write()
{
//! [scatter_write]
@@ -171,7 +257,7 @@ void mapped_file()
// default flags is none
).value(); // If failed, throw a filesystem_error exception
- auto length = mh.length().value();
+ auto length = mh.maximum_extent().value();
// Find my text
for (char *p = reinterpret_cast<char *>(mh.address()); (p = (char *)memchr(p, 'h', reinterpret_cast<char *>(mh.address()) + length - p)); p++)
diff --git a/include/afio/revision.hpp b/include/afio/revision.hpp
index 2989e199..e7e3feb9 100644
--- a/include/afio/revision.hpp
+++ b/include/afio/revision.hpp
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
-#define AFIO_PREVIOUS_COMMIT_REF ed04b40b799d1cb2b4c1787b9a1089050e3c89ae
-#define AFIO_PREVIOUS_COMMIT_DATE "2018-04-08 01:51:32 +00:00"
-#define AFIO_PREVIOUS_COMMIT_UNIQUE ed04b40b
+#define AFIO_PREVIOUS_COMMIT_REF 4e837be97c2972e11a8515ae260e4476bd6654e3
+#define AFIO_PREVIOUS_COMMIT_DATE "2018-04-11 11:25:46 +00:00"
+#define AFIO_PREVIOUS_COMMIT_UNIQUE 4e837be9
diff --git a/include/afio/v2.0/algorithm/mapped_span.hpp b/include/afio/v2.0/algorithm/mapped_span.hpp
index 52ada81e..175eb839 100644
--- a/include/afio/v2.0/algorithm/mapped_span.hpp
+++ b/include/afio/v2.0/algorithm/mapped_span.hpp
@@ -101,8 +101,8 @@ namespace algorithm
\param length The number of items to map, use -1 to mean the length of the section handle divided by `sizeof(T)`.
\param byteoffset The byte offset into the mapped file handle, this does not need to be a multiple of the page size.
*/
- explicit mapped_span(mapped_file_handle &mfh, size_type length = (size_type) -1, extent_type byteoffset = 0) // NOLINT
- : span<T>(reinterpret_cast<T *>(mfh.address() + byteoffset), (length == (size_type) -1) ? (mfh.length().value() / sizeof(T)) : length) // NOLINT
+ explicit mapped_span(mapped_file_handle &mfh, size_type length = (size_type) -1, extent_type byteoffset = 0) // NOLINT
+ : span<T>(reinterpret_cast<T *>(mfh.address() + byteoffset), (length == (size_type) -1) ? (mfh.maximum_extent().value() / sizeof(T)) : length) // NOLINT
{
}
};
diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp
index 8fdfdfe4..b9cd42fd 100644
--- a/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp
+++ b/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp
@@ -274,7 +274,7 @@ namespace algorithm
lock_request.hash = QUICKCPPLIB_NAMESPACE::algorithm::hash::fast_hash::hash((reinterpret_cast<char *>(&lock_request)) + 16, sizeof(lock_request) - 16);
}
// My lock request will be the file's current length or higher
- OUTCOME_TRY(my_lock_request_offset, _h.length());
+ OUTCOME_TRY(my_lock_request_offset, _h.maximum_extent());
{
OUTCOME_TRYV(_h.set_append_only(true));
auto undo = undoer([this] { (void) _h.set_append_only(false); });
diff --git a/include/afio/v2.0/detail/impl/posix/file_handle.ipp b/include/afio/v2.0/detail/impl/posix/file_handle.ipp
index 3b3afa98..7ad66d1f 100644
--- a/include/afio/v2.0/detail/impl/posix/file_handle.ipp
+++ b/include/afio/v2.0/detail/impl/posix/file_handle.ipp
@@ -338,7 +338,7 @@ result<file_handle> file_handle::clone(mode mode_, caching caching_, deadline d)
}
}
-result<file_handle::extent_type> file_handle::length() const noexcept
+result<file_handle::extent_type> file_handle::maximum_extent() const noexcept
{
AFIO_LOG_FUNCTION_CALL(this);
struct stat s
@@ -414,7 +414,7 @@ result<std::vector<std::pair<file_handle::extent_type, file_handle::extent_type>
// If it failed with no output, probably this filing system doesn't support extents
if(out.empty())
{
- OUTCOME_TRY(size, file_handle::length());
+ OUTCOME_TRY(size, file_handle::maximum_extent());
out.emplace_back(0, size);
return out;
}
diff --git a/include/afio/v2.0/detail/impl/posix/mapped_file_handle.ipp b/include/afio/v2.0/detail/impl/posix/mapped_file_handle.ipp
index 8999a655..6552ed07 100644
--- a/include/afio/v2.0/detail/impl/posix/mapped_file_handle.ipp
+++ b/include/afio/v2.0/detail/impl/posix/mapped_file_handle.ipp
@@ -30,7 +30,7 @@ AFIO_V2_NAMESPACE_BEGIN
result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type reservation) noexcept
{
AFIO_LOG_FUNCTION_CALL(this);
- OUTCOME_TRY(length, underlying_file_length());
+ OUTCOME_TRY(length, underlying_file_maximum_extent());
if(length == 0)
{
// Not portable to map an empty file, so fail
@@ -137,7 +137,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type
result<mapped_file_handle::extent_type> mapped_file_handle::update_map() noexcept
{
- OUTCOME_TRY(length, underlying_file_length());
+ OUTCOME_TRY(length, underlying_file_maximum_extent());
if(length > _reservation)
{
// This API never exceeds the reservation
diff --git a/include/afio/v2.0/detail/impl/storage_profile.ipp b/include/afio/v2.0/detail/impl/storage_profile.ipp
index 034b8dcc..cd526fcc 100644
--- a/include/afio/v2.0/detail/impl/storage_profile.ipp
+++ b/include/afio/v2.0/detail/impl/storage_profile.ipp
@@ -904,7 +904,7 @@ namespace storage_profile
file_handle::const_buffer_type _reqs[1] = {{buffer, 4096}};
file_handle::io_request<file_handle::const_buffers_type> reqs(_reqs, 0);
QUICKCPPLIB_NAMESPACE::algorithm::small_prng::small_prng rand(static_cast<uint32_t>(no));
- auto maxsize = h.length().value();
+ auto maxsize = h.maximum_extent().value();
--done;
while(done != 0u)
{
@@ -943,7 +943,7 @@ namespace storage_profile
file_handle::buffer_type _reqs[1] = {{buffer, 4096}};
file_handle::io_request<file_handle::buffers_type> reqs(_reqs, 0);
QUICKCPPLIB_NAMESPACE::algorithm::small_prng::small_prng rand(static_cast<uint32_t>(no));
- auto maxsize = h.length().value();
+ auto maxsize = h.maximum_extent().value();
--done;
while(done != 0u)
{
diff --git a/include/afio/v2.0/detail/impl/windows/file_handle.ipp b/include/afio/v2.0/detail/impl/windows/file_handle.ipp
index 1346d635..4b9fbd19 100644
--- a/include/afio/v2.0/detail/impl/windows/file_handle.ipp
+++ b/include/afio/v2.0/detail/impl/windows/file_handle.ipp
@@ -364,7 +364,7 @@ result<file_handle> file_handle::clone(mode mode_, caching caching_, deadline /*
return ret;
}
-result<file_handle::extent_type> file_handle::length() const noexcept
+result<file_handle::extent_type> file_handle::maximum_extent() const noexcept
{
AFIO_LOG_FUNCTION_CALL(this);
#if 0
diff --git a/include/afio/v2.0/detail/impl/windows/map_handle.ipp b/include/afio/v2.0/detail/impl/windows/map_handle.ipp
index 0b8b2999..15102935 100644
--- a/include/afio/v2.0/detail/impl/windows/map_handle.ipp
+++ b/include/afio/v2.0/detail/impl/windows/map_handle.ipp
@@ -249,7 +249,7 @@ result<section_handle::extent_type> section_handle::truncate(extent_type newsize
{
if(_backing != nullptr)
{
- OUTCOME_TRY(length, _backing->length());
+ OUTCOME_TRY(length, _backing->maximum_extent());
newsize = length;
}
else
diff --git a/include/afio/v2.0/detail/impl/windows/mapped_file_handle.ipp b/include/afio/v2.0/detail/impl/windows/mapped_file_handle.ipp
index f6e713df..d5ea2d40 100644
--- a/include/afio/v2.0/detail/impl/windows/mapped_file_handle.ipp
+++ b/include/afio/v2.0/detail/impl/windows/mapped_file_handle.ipp
@@ -32,7 +32,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese
AFIO_LOG_FUNCTION_CALL(this);
if(reservation == 0)
{
- OUTCOME_TRY(length, underlying_file_length());
+ OUTCOME_TRY(length, underlying_file_maximum_extent());
reservation = length;
}
reservation = utils::round_up_to_page_size(reservation);
@@ -142,7 +142,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type
result<mapped_file_handle::extent_type> mapped_file_handle::update_map() noexcept
{
- OUTCOME_TRY(length, underlying_file_length());
+ OUTCOME_TRY(length, underlying_file_maximum_extent());
if(length > _reservation)
{
// This API never exceeds the reservation
diff --git a/include/afio/v2.0/file_handle.hpp b/include/afio/v2.0/file_handle.hpp
index aee52b61..895b494b 100644
--- a/include/afio/v2.0/file_handle.hpp
+++ b/include/afio/v2.0/file_handle.hpp
@@ -235,7 +235,7 @@ public:
\errors Any of the values POSIX fstat() or GetFileInformationByHandleEx() can return.
*/
AFIO_MAKE_FREE_FUNCTION
- AFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> length() const noexcept;
+ AFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> maximum_extent() const noexcept;
/*! Resize the current maximum permitted extent of the file to the given extent, avoiding any
new allocation of physical storage where supported. Note that on extents based filing systems
@@ -249,6 +249,9 @@ public:
AFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> truncate(extent_type newsize) noexcept;
/*! \brief Returns a list of currently valid extents for this open file. WARNING: racy!
+ \return A vector of pairs of extent offset + extent length representing the valid extents
+ in this file. Filing systems which do not support extents return a single extent matching
+ the length of the file rather than returning an error.
*/
AFIO_MAKE_FREE_FUNCTION
AFIO_HEADERS_ONLY_VIRTUAL_SPEC result<std::vector<std::pair<extent_type, extent_type>>> extents() const noexcept;
@@ -304,7 +307,8 @@ inline void swap(file_handle &self, file_handle &o) noexcept
\errors Any of the values POSIX open() or CreateFile() can return.
*/
-inline result<file_handle> file(const path_handle &base, file_handle::path_view_type path, file_handle::mode _mode = file_handle::mode::read, file_handle::creation _creation = file_handle::creation::open_existing, file_handle::caching _caching = file_handle::caching::all, file_handle::flag flags = file_handle::flag::none) noexcept
+inline result<file_handle> file(const path_handle &base, file_handle::path_view_type path, file_handle::mode _mode = file_handle::mode::read, file_handle::creation _creation = file_handle::creation::open_existing, file_handle::caching _caching = file_handle::caching::all,
+ file_handle::flag flags = file_handle::flag::none) noexcept
{
return file_handle::file(std::forward<decltype(base)>(base), std::forward<decltype(path)>(path), std::forward<decltype(_mode)>(_mode), std::forward<decltype(_creation)>(_creation), std::forward<decltype(_caching)>(_caching), std::forward<decltype(flags)>(flags));
}
@@ -335,7 +339,8 @@ to use. Use `temp_inode()` instead, it is far more secure.
\errors Any of the values POSIX open() or CreateFile() can return.
*/
-inline result<file_handle> temp_file(file_handle::path_view_type name = file_handle::path_view_type(), file_handle::mode _mode = file_handle::mode::write, file_handle::creation _creation = file_handle::creation::if_needed, file_handle::caching _caching = file_handle::caching::temporary, file_handle::flag flags = file_handle::flag::unlink_on_close) noexcept
+inline result<file_handle> temp_file(file_handle::path_view_type name = file_handle::path_view_type(), file_handle::mode _mode = file_handle::mode::write, file_handle::creation _creation = file_handle::creation::if_needed, file_handle::caching _caching = file_handle::caching::temporary,
+ file_handle::flag flags = file_handle::flag::unlink_on_close) noexcept
{
return file_handle::temp_file(std::forward<decltype(name)>(name), std::forward<decltype(_mode)>(_mode), std::forward<decltype(_creation)>(_creation), std::forward<decltype(_caching)>(_caching), std::forward<decltype(flags)>(flags));
}
@@ -357,9 +362,9 @@ inline result<file_handle> temp_inode(const path_handle &dirh = path_discovery::
\errors Any of the values POSIX fstat() or GetFileInformationByHandleEx() can return.
*/
-inline result<file_handle::extent_type> length(const file_handle &self) noexcept
+inline result<file_handle::extent_type> maximum_extent(const file_handle &self) noexcept
{
- return self.length();
+ return self.maximum_extent();
}
/*! Resize the current maximum permitted extent of the file to the given extent, avoiding any
new allocation of physical storage where supported. Note that on extents based filing systems
diff --git a/include/afio/v2.0/map_handle.hpp b/include/afio/v2.0/map_handle.hpp
index bceac389..567c7c5c 100644
--- a/include/afio/v2.0/map_handle.hpp
+++ b/include/afio/v2.0/map_handle.hpp
@@ -120,7 +120,7 @@ public:
/*! \brief Create a memory section backed by a file.
\param backing The handle to use as backing storage.
- \param maximum_size The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.length()`.
+ \param maximum_size The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.maximum_extent()`.
\param _flag How to create the section.
\errors Any of the values POSIX dup(), open() or NtCreateSection() can return.
@@ -129,7 +129,7 @@ public:
static AFIO_HEADERS_ONLY_MEMFUNC_SPEC result<section_handle> section(file_handle &backing, extent_type maximum_size, flag _flag) noexcept;
/*! \brief Create a memory section backed by a file.
\param backing The handle to use as backing storage.
- \param bytes The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.length()`.
+ \param bytes The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.maximum_extent()`.
This convenience overload create a writable section if the backing file is writable, otherwise a read-only section.
@@ -157,12 +157,12 @@ public:
void set_backing(file_handle *fh) noexcept { _backing = fh; }
//! Returns the borrowed native handle backing this section
native_handle_type backing_native_handle() const noexcept { return _backing != nullptr ? _backing->native_handle() : native_handle_type(); }
- //! Return the current maximum permitted extent of the memory section.
+ //! Return the current length of the memory section.
AFIO_MAKE_FREE_FUNCTION
AFIO_HEADERS_ONLY_MEMFUNC_SPEC result<extent_type> length() const noexcept;
/*! Resize the current maximum permitted extent of the memory section to the given extent.
- \param newsize The new size of the memory section, which cannot be zero. Specify zero to use `backing.length()`.
+ \param newsize The new size of the memory section, which cannot be zero. Specify zero to use `backing.maximum_extent()`.
This cannot exceed the size of any backing file used if that file is not writable.
\errors Any of the values `NtExtendSection()` or `ftruncate()` can return.
@@ -549,7 +549,7 @@ inline void swap(section_handle &self, section_handle &o) noexcept
}
/*! \brief Create a memory section backed by a file.
\param backing The handle to use as backing storage.
-\param maximum_size The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.length()`.
+\param maximum_size The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.maximum_extent()`.
\param _flag How to create the section.
\errors Any of the values POSIX dup(), open() or NtCreateSection() can return.
@@ -560,7 +560,7 @@ inline result<section_handle> section(file_handle &backing, section_handle::exte
}
/*! \brief Create a memory section backed by a file.
\param backing The handle to use as backing storage.
-\param bytes The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.length()`.
+\param bytes The initial size of this section, which cannot be larger than any backing file. Zero means to use `backing.maximum_extent()`.
This convenience overload create a writable section if the backing file is writable, otherwise a read-only section.
@@ -588,7 +588,7 @@ inline result<section_handle::extent_type> length(const section_handle &self) no
}
/*! Resize the current maximum permitted extent of the memory section to the given extent.
\param self The object whose member function to call.
-\param newsize The new size of the memory section, which cannot be zero. Specify zero to use `backing.length()`.
+\param newsize The new size of the memory section, which cannot be zero. Specify zero to use `backing.maximum_extent()`.
This cannot exceed the size of any backing file used if that file is not writable.
\errors Any of the values `NtExtendSection()` or `ftruncate()` can return.
diff --git a/include/afio/v2.0/mapped_file_handle.hpp b/include/afio/v2.0/mapped_file_handle.hpp
index 21ead25c..4fb459b3 100644
--- a/include/afio/v2.0/mapped_file_handle.hpp
+++ b/include/afio/v2.0/mapped_file_handle.hpp
@@ -84,8 +84,8 @@ or not yet. You are guaranteed that `address()` will not return a new
value unless you truncate from a bigger length to a smaller length, or you call `reserve()`
with a new reservation or `truncate()` with a value bigger than the reservation.
-`length()` reports the last truncated length of the mapped file (possibly by any process in
-the system) up to the reservation limit, NOT the length of the underlying file.
+`maximum_extent()` reports the last truncated length of the mapped file (possibly by any process in
+the system) up to the reservation limit, NOT the maximum extent of the underlying file.
When you know that another process has extended the file and you wish to map the newly appended
data, you can call `update_map()` which guarantees that the mapping your
process sees is up to date, rather than relying on any kernel-specific automatic mapping.
@@ -296,8 +296,8 @@ public:
//! The address in memory where this mapped file resides
byte *address() const noexcept { return _mh.address(); }
- //! The length of the underlying file
- result<extent_type> underlying_file_length() const noexcept { return file_handle::length(); }
+ //! The maximum extent of the underlying file
+ result<extent_type> underlying_file_maximum_extent() const noexcept { return file_handle::maximum_extent(); }
//! The address space (to be) reserved for future expansion of this file.
size_type capacity() const noexcept { return _reservation; }
@@ -333,7 +333,7 @@ public:
return mapped_file_handle(std::move(fh), reservation);
}
//! Return the current maximum permitted extent of the file.
- AFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> length() const noexcept override { return _mh.length(); }
+ AFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> maximum_extent() const noexcept override { return _mh.length(); }
/*! \brief Resize the current maximum permitted extent of the mapped file to the given extent, avoiding any
new allocation of physical storage where supported, and mapping or unmapping any new pages
diff --git a/include/afio/v2.0/outcome b/include/afio/v2.0/outcome
-Subproject 5188e87c55b19b58eb94a52b6119ddd39837597
+Subproject 1521b808351b623d1a19acb0a2eb455785a0a5d
diff --git a/test/tests/map_handle_create_close/runner.cpp b/test/tests/map_handle_create_close/runner.cpp
index b0e4abfd..087f77cc 100644
--- a/test/tests/map_handle_create_close/runner.cpp
+++ b/test/tests/map_handle_create_close/runner.cpp
@@ -148,7 +148,7 @@ template <class U> inline void map_handle_create_close_(U &&f)
// The OS should not auto expand storage to 4Kb
if (use_file_backing)
{
- KERNELTEST_CHECK(testreturn, temph.length().value() == 19);
+ KERNELTEST_CHECK(testreturn, temph.maximum_extent().value() == 19);
}
}
}
diff --git a/test/tests/mapped_span.cpp b/test/tests/mapped_span.cpp
index 469a1453..14a5384a 100644
--- a/test/tests/mapped_span.cpp
+++ b/test/tests/mapped_span.cpp
@@ -47,7 +47,7 @@ static inline void TestMappedView1()
{
// Overly large views must not extend the file until written to
algorithm::mapped_span<int> v4(sh, 20000);
- BOOST_CHECK(fh.length().value() == 10000 * sizeof(int));
+ BOOST_CHECK(fh.maximum_extent().value() == 10000 * sizeof(int));
}
catch(...)
{
@@ -81,8 +81,8 @@ static inline void TestMappedView2()
v1[9999] = 79;
mfh.truncate(20000 * sizeof(int)).value();
BOOST_CHECK(addr == mfh.address());
- BOOST_CHECK(mfh.length().value() == 20000 * sizeof(int));
- BOOST_CHECK(mfh.underlying_file_length().value() == 20000 * sizeof(int));
+ BOOST_CHECK(mfh.maximum_extent().value() == 20000 * sizeof(int));
+ BOOST_CHECK(mfh.underlying_file_maximum_extent().value() == 20000 * sizeof(int));
v1 = algorithm::mapped_span<int>(mfh);
BOOST_CHECK(v1.size() == 20000);
BOOST_CHECK(v1[0] == 78);