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-07-12 12:00:14 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-07-12 12:00:14 +0300
commitf743a7358ec186a3982d1a61dad2120ba9305180 (patch)
tree4bd8ca4422d7659e7224ae8343ea5d3b58b5a295
parent11d4f9dbc12a61a796c8c00f260924ee17aa3cc1 (diff)
Split algorithm::mapped_span<T> into map_view<T> and mapped<T>, as per the TS wording.
-rw-r--r--cmake/headers.cmake3
-rw-r--r--cmake/tests.cmake2
-rw-r--r--example/use_cases.cpp12
-rw-r--r--include/llfio/revision.hpp6
-rw-r--r--include/llfio/v2.0/llfio.hpp3
-rw-r--r--include/llfio/v2.0/map_view.hpp87
-rw-r--r--include/llfio/v2.0/mapped.hpp108
-rw-r--r--include/llfio/v2.0/mapped_view.hpp124
-rw-r--r--test/tests/mapped.cpp (renamed from test/tests/mapped_span.cpp)28
9 files changed, 222 insertions, 151 deletions
diff --git a/cmake/headers.cmake b/cmake/headers.cmake
index e59c5577..01211f26 100644
--- a/cmake/headers.cmake
+++ b/cmake/headers.cmake
@@ -7,7 +7,6 @@ set(llfio_HEADERS
"include/llfio/ntkernel-error-category/include/ntkernel_category.hpp"
"include/llfio/revision.hpp"
"include/llfio/v2.0/algorithm/cached_parent_handle_adapter.hpp"
- "include/llfio/v2.0/algorithm/mapped_span.hpp"
"include/llfio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp"
"include/llfio/v2.0/algorithm/shared_fs_mutex/base.hpp"
"include/llfio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp"
@@ -28,6 +27,8 @@ set(llfio_HEADERS
"include/llfio/v2.0/llfio.hpp"
"include/llfio/v2.0/logging.hpp"
"include/llfio/v2.0/map_handle.hpp"
+ "include/llfio/v2.0/map_view.hpp"
+ "include/llfio/v2.0/mapped.hpp"
"include/llfio/v2.0/mapped_file_handle.hpp"
"include/llfio/v2.0/native_handle_type.hpp"
"include/llfio/v2.0/path_discovery.hpp"
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
index 02167128..a0b676b2 100644
--- a/cmake/tests.cmake
+++ b/cmake/tests.cmake
@@ -15,7 +15,7 @@ set(llfio_TESTS
"test/tests/file_handle_create_close/runner.cpp"
"test/tests/file_handle_lock_unlock.cpp"
"test/tests/map_handle_create_close/runner.cpp"
- "test/tests/mapped_span.cpp"
+ "test/tests/mapped.cpp"
"test/tests/path_discovery.cpp"
"test/tests/path_view.cpp"
"test/tests/section_handle_create_close/runner.cpp"
diff --git a/example/use_cases.cpp b/example/use_cases.cpp
index 640837f6..26058a52 100644
--- a/example/use_cases.cpp
+++ b/example/use_cases.cpp
@@ -224,7 +224,7 @@ void malloc1()
mh.do_not_store({mh.address(), mh.length()}).value();
// Fill the memory with 'b' C++ style, probably faulting new pages into existence
- llfio::algorithm::mapped_span<char> p2(mh);
+ llfio::map_view<char> p2(mh);
std::fill(p2.begin(), p2.end(), 'b');
// Kick the contents of the memory out to the swap file so it is no longer cached in RAM
@@ -245,7 +245,7 @@ void malloc1()
// You can actually save yourself some time and skip manually creating map handles.
// Just construct a mapped_span directly, this creates an internal map_handle instance,
// so memory is released when the span is destroyed
- llfio::algorithm::mapped_span<float> f(1000); // 1000 floats, allocated used mmap()
+ llfio::mapped<float> f(1000); // 1000 floats, allocated used mmap()
std::fill(f.begin(), f.end(), 1.23f);
//! [malloc1]
}
@@ -263,18 +263,18 @@ void malloc2()
{
// Map it into memory, and fill it with 'a'
- llfio::algorithm::mapped_span<char> ms1(sh);
+ llfio::mapped<char> ms1(sh);
std::fill(ms1.begin(), ms1.end(), 'a');
// Destructor unmaps it from memory
}
// Map it into memory again, verify it contains 'a'
- llfio::algorithm::mapped_span<char> ms1(sh);
+ llfio::mapped<char> ms1(sh);
assert(ms1[0] == 'a');
// Map a *second view* of the same memory
- llfio::algorithm::mapped_span<char> ms2(sh);
+ llfio::mapped<char> ms2(sh);
assert(ms2[0] == 'a');
// The addresses of the two maps are unique
@@ -380,7 +380,7 @@ void sparse_array()
(void) mfh.truncate(1000000000000ULL * sizeof(int));
// Create a typed view of the one trillion integers
- llfio::algorithm::mapped_span<int> one_trillion_int_array(mfh);
+ llfio::map_view<int> one_trillion_int_array(mfh);
// Write and read as you see fit, if you exceed physical RAM it'll be paged out
one_trillion_int_array[0] = 5;
diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp
index 170a3b7e..686af442 100644
--- a/include/llfio/revision.hpp
+++ b/include/llfio/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 LLFIO_PREVIOUS_COMMIT_REF 87cfaf9bd54b9dca5adfd9263a86d7af45a297b3
-#define LLFIO_PREVIOUS_COMMIT_DATE "2018-07-11 18:08:32 +00:00"
-#define LLFIO_PREVIOUS_COMMIT_UNIQUE 87cfaf9b
+#define LLFIO_PREVIOUS_COMMIT_REF 11d4f9dbc12a61a796c8c00f260924ee17aa3cc1
+#define LLFIO_PREVIOUS_COMMIT_DATE "2018-07-12 08:22:14 +00:00"
+#define LLFIO_PREVIOUS_COMMIT_UNIQUE 11d4f9db
diff --git a/include/llfio/v2.0/llfio.hpp b/include/llfio/v2.0/llfio.hpp
index b5399af6..4fee0f54 100644
--- a/include/llfio/v2.0/llfio.hpp
+++ b/include/llfio/v2.0/llfio.hpp
@@ -68,14 +68,13 @@ import LLFIO_MODULE_NAME;
#include "file_handle.hpp"
#endif
#include "directory_handle.hpp"
-#include "map_handle.hpp"
+#include "map_view.hpp"
#include "statfs.hpp"
#ifndef LLFIO_LEAN_AND_MEAN
#include "storage_profile.hpp"
#endif
#include "algorithm/cached_parent_handle_adapter.hpp"
-#include "algorithm/mapped_span.hpp"
#include "algorithm/shared_fs_mutex/atomic_append.hpp"
#include "algorithm/shared_fs_mutex/byte_ranges.hpp"
#include "algorithm/shared_fs_mutex/lock_files.hpp"
diff --git a/include/llfio/v2.0/map_view.hpp b/include/llfio/v2.0/map_view.hpp
new file mode 100644
index 00000000..b4811891
--- /dev/null
+++ b/include/llfio/v2.0/map_view.hpp
@@ -0,0 +1,87 @@
+/* A typed view of a mapped section
+(C) 2017-2018 Niall Douglas <http://www.nedproductions.biz/> (12 commits)
+File Created: Aug 2017
+
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License in the accompanying file
+Licence.txt or at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file Licence.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+#ifndef LLFIO_MAP_VIEW_HPP
+#define LLFIO_MAP_VIEW_HPP
+
+#include "mapped.hpp"
+
+//! \file map_view.hpp Provides typed view of mapped section.
+
+LLFIO_V2_NAMESPACE_BEGIN
+
+/*! \brief Provides a lightweight typed view of a `map_handle`, a `mapped_file_handle`
+or a `mapped<T>` suitable for feeding to STL algorithms or the Ranges TS.
+
+This is the correct type to use when passing non-owning views of mapped data
+around between functions. Where you wish the view to be (possibly) owning,
+you may find the non-lightweight `mapped<T>` of more use.
+*/
+template <class T> class map_view : public span<T>
+{
+public:
+ //! The extent type.
+ using extent_type = typename section_handle::extent_type;
+ //! The size type.
+ using size_type = typename section_handle::size_type;
+
+public:
+ //! Default constructor
+ constexpr map_view() {} // NOLINT
+
+ /*! Implicitly construct a mapped view of the given mapped data.
+
+ \param map The mapped data to take a view upon.
+ \param length The number of items to map, use -1 to mean the length of the input view.
+ \param byteoffset The item offset into the mapped file handle.
+ */
+ map_view(mapped<T> &map, size_type length = (size_type) -1, size_type offset = 0) // NOLINT
+ : span<T>(map.begin() + offset, (length == (size_type) -1) ? (map.size() - offset) : length) // NOLINT
+ {
+ }
+ /*! Construct a mapped view of the given map handle.
+
+ \param mh The map handle to use.
+ \param length The number of items to map, use -1 to mean the length of the map handle divided by `sizeof(T)`.
+ \param byteoffset The byte offset into the map handle, this does not need to be a multiple of the page size.
+ */
+ explicit map_view(map_handle &mh, size_type length = (size_type) -1, extent_type byteoffset = 0) // NOLINT
+ : span<T>(reinterpret_cast<T *>(mh.address() + byteoffset), (length == (size_type) -1) ? ((mh.length() - byteoffset) / sizeof(T)) : length) // NOLINT
+ {
+ }
+ /*! Construct a mapped view of the given mapped file handle.
+
+ \param mfh The mapped file handle to take a view upon.
+ \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 map_view(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() - byteoffset) / sizeof(T)) : length) // NOLINT
+ {
+ }
+};
+
+LLFIO_V2_NAMESPACE_END
+
+#endif
diff --git a/include/llfio/v2.0/mapped.hpp b/include/llfio/v2.0/mapped.hpp
new file mode 100644
index 00000000..6a023f23
--- /dev/null
+++ b/include/llfio/v2.0/mapped.hpp
@@ -0,0 +1,108 @@
+/* A typed view of a mapped section
+(C) 2017-2018 Niall Douglas <http://www.nedproductions.biz/> (12 commits)
+File Created: Aug 2017
+
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License in the accompanying file
+Licence.txt or at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file Licence.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+#ifndef LLFIO_MAPPED_HPP
+#define LLFIO_MAPPED_HPP
+
+#include "mapped_file_handle.hpp"
+#include "utils.hpp"
+
+//! \file mapped.hpp Provides typed view of mapped section.
+
+LLFIO_V2_NAMESPACE_BEGIN
+
+/*! \brief Provides a map owning typed view of a `section_handle` suitable for feeding to STL algorithms
+or the Ranges TS by wrapping a `map_handle` into a `span<T>`.
+
+This opens a new `map_handle` onto the requested offset and length of the supplied source, and thus
+is an *owning* view of mapped memory. It can be moved, but not copied. If you wish to pass a non-owning
+view, see `map_view<T>`.
+
+Optionally can issue a blocking write barrier on destruction of the mapped view by setting the flag
+`section_handle::flag::barrier_on_close`, thus forcing any changes to data referred to by the view
+to storage before the destructor returns.
+*/
+template <class T> class mapped : public span<T>
+{
+public:
+ //! The extent type.
+ using extent_type = typename section_handle::extent_type;
+ //! The size type.
+ using size_type = typename section_handle::size_type;
+
+private:
+ map_handle _mapping;
+ mapped(extent_type page_offset, extent_type offset, section_handle &sh, size_type bytes, section_handle::flag _flag) // NOLINT
+ : _mapping(map_handle::map(sh, (bytes == 0) ? 0 : bytes + (offset - page_offset), page_offset, _flag).value())
+ {
+ offset -= page_offset;
+ byte *addr = _mapping.address() + offset;
+ size_t len = sh.length().value() - offset; // use section length, not mapped length as mapped length is rounded up to page size
+ if(bytes != 0 && bytes < len)
+ {
+ len = bytes;
+ }
+ static_cast<span<T> &>(*this) = span<T>(reinterpret_cast<T *>(addr), len / sizeof(T)); // NOLINT
+ }
+
+public:
+ //! Default constructor
+ constexpr mapped() {} // NOLINT
+
+ //! Returns a reference to the internal map handle
+ const map_handle &map_handle() const noexcept { return _mapping; }
+
+ /*! Create a view of new memory.
+
+ \param length The number of items to map.
+ \param _flag The flags to pass to `map_handle::map()`.
+ */
+ explicit mapped(size_type length, section_handle::flag _flag = section_handle::flag::readwrite)
+ : _mapping(map_handle::map(length * sizeof(T), _flag).value())
+ {
+ byte *addr = _mapping.address();
+ static_cast<span<T> &>(*this) = span<T>(reinterpret_cast<T *>(addr), length); // NOLINT
+ }
+ /*! Construct a mapped view of the given section handle.
+
+ \param sh The section handle to use as the data source for creating the map.
+ \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 section handle, this does not need to be a multiple of the page size.
+ \param _flag The flags to pass to `map_handle::map()`.
+ */
+ explicit mapped(section_handle &sh, size_type length = (size_type) -1, extent_type byteoffset = 0, section_handle::flag _flag = section_handle::flag::readwrite) // NOLINT
+ : mapped((length == 0) ? mapped() : mapped(
+#ifdef _WIN32
+ byteoffset & ~65535,
+#else
+ utils::round_down_to_page_size(byteoffset),
+#endif
+ byteoffset, sh, (length == (size_type) -1) ? 0 : length * sizeof(T), _flag)) // NOLINT
+ {
+ }
+};
+
+LLFIO_V2_NAMESPACE_END
+
+#endif
diff --git a/include/llfio/v2.0/mapped_view.hpp b/include/llfio/v2.0/mapped_view.hpp
deleted file mode 100644
index 1bb0c84b..00000000
--- a/include/llfio/v2.0/mapped_view.hpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/* A typed view of a mapped section
-(C) 2017 Niall Douglas <http://www.nedproductions.biz/> (12 commits)
-File Created: Aug 2017
-
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License in the accompanying file
-Licence.txt or at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-
-Distributed under the Boost Software License, Version 1.0.
- (See accompanying file Licence.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-*/
-
-#ifndef LLFIO_MAPPED_VIEW_HPP
-#define LLFIO_MAPPED_VIEW_HPP
-
-#include "../mapped_file_handle.hpp"
-#include "../utils.hpp"
-
-//! \file mapped_span.hpp Provides typed view of mapped section.
-
-LLFIO_V2_NAMESPACE_BEGIN
-
-namespace algorithm
-{
- /*! \brief Provides a typed mapped view of a `section_handle` suitable for feeding to STL algorithms
- or the Ranges TS by wrapping a `map_handle` into a `span<T>`.
-
- Optionally can issue a blocking write barrier on destruction of the mapped view by setting the flag
- `section_handle::flag::barrier_on_close`, thus forcing any changes to data referred to by the view
- to storage before the destructor returns.
- */
- template <class T> class mapped_span : public span<T>
- {
- public:
- //! The extent type.
- using extent_type = typename section_handle::extent_type;
- //! The size type.
- using size_type = typename section_handle::size_type;
-
- private:
- map_handle _mapping;
- mapped_span(extent_type page_offset, extent_type offset, section_handle &sh, size_type bytes, section_handle::flag _flag) // NOLINT
- : _mapping(map_handle::map(sh, (bytes == 0) ? 0 : bytes + (offset - page_offset), page_offset, _flag).value())
- {
- offset -= page_offset;
- byte *addr = _mapping.address() + offset;
- size_t len = sh.length().value() - offset; // use section length, not mapped length as mapped length is rounded up to page size
- if(bytes != 0 && bytes < len)
- {
- len = bytes;
- }
- static_cast<span<T> &>(*this) = span<T>(reinterpret_cast<T *>(addr), len / sizeof(T)); // NOLINT
- }
-
- public:
- //! Default constructor
- constexpr mapped_span() {} // NOLINT
-
- /*! Create a view of new memory.
-
- \param length The number of items to map.
- \param _flag The flags to pass to `map_handle::map()`.
- */
- explicit mapped_span(size_type length, section_handle::flag _flag = section_handle::flag::readwrite)
- : _mapping(map_handle::map(length * sizeof(T), _flag).value())
- {
- byte *addr = _mapping.address();
- static_cast<span<T> &>(*this) = span<T>(reinterpret_cast<T *>(addr), length); // NOLINT
- }
- /*! Construct a mapped view of the given section handle.
-
- \param sh The section handle to use as the data source for creating the map.
- \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 section handle, this does not need to be a multiple of the page size.
- \param _flag The flags to pass to `map_handle::map()`.
- */
- explicit mapped_span(section_handle &sh, size_type length = (size_type) -1, extent_type byteoffset = 0, section_handle::flag _flag = section_handle::flag::readwrite) // NOLINT
- : mapped_span((length == 0) ? mapped_span() : mapped_span(
-#ifdef _WIN32
- byteoffset & ~65535,
-#else
- utils::round_down_to_page_size(byteoffset),
-#endif
- byteoffset, sh, (length == (size_type) -1) ? 0 : length * sizeof(T), _flag)) // NOLINT
- {
- }
- /*! Construct a mapped view of the given map handle.
-
- \param mh The map handle to use.
- \param length The number of items to map, use -1 to mean the length of the map handle divided by `sizeof(T)`.
- \param byteoffset The byte offset into the map handle, this does not need to be a multiple of the page size.
- */
- explicit mapped_span(map_handle &mh, size_type length = (size_type) -1, extent_type byteoffset = 0) // NOLINT
- : span<T>(reinterpret_cast<T *>(mh.address() + byteoffset), (length == (size_type) -1) ? ((mh.length() - byteoffset) / sizeof(T)) : length) // NOLINT
- {
- }
- /*! Construct a mapped view of the given mapped file handle.
-
- \param mfh The mapped file handle to use as the data source for creating the map.
- \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.maximum_extent().value() - byteoffset) / sizeof(T)) : length) // NOLINT
- {
- }
- };
-} // namespace algorithm
-
-LLFIO_V2_NAMESPACE_END
-
-#endif
diff --git a/test/tests/mapped_span.cpp b/test/tests/mapped.cpp
index af32c200..018d7e09 100644
--- a/test/tests/mapped_span.cpp
+++ b/test/tests/mapped.cpp
@@ -31,9 +31,9 @@ static inline void TestMappedView1()
file_handle fh = file_handle::file({}, "testfile", file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::all, file_handle::flag::unlink_on_first_close).value();
fh.truncate(10000 * sizeof(int)).value();
section_handle sh(section_handle::section(fh).value());
- algorithm::mapped_span<int> v1(sh, 5);
- algorithm::mapped_span<int> v2(sh);
- algorithm::mapped_span<int> v3(50);
+ mapped<int> v1(sh, 5);
+ mapped<int> v2(sh);
+ mapped<int> v3(50);
BOOST_CHECK(v1.size() == 5);
BOOST_CHECK(v2.size() == 10000);
BOOST_CHECK(v3.size() == 50);
@@ -46,7 +46,7 @@ static inline void TestMappedView1()
try
{
// Overly large views must not extend the file until written to
- algorithm::mapped_span<int> v4(sh, 20000);
+ mapped<int> v4(sh, 20000);
BOOST_CHECK(fh.maximum_extent().value() == 10000 * sizeof(int));
}
catch(...)
@@ -75,7 +75,7 @@ static inline void TestMappedView2()
byte *addr = mfh.address();
BOOST_CHECK(addr != nullptr);
- algorithm::mapped_span<int> v1(mfh);
+ map_view<int> v1(mfh);
BOOST_CHECK(v1.size() == 10000);
v1[0] = 78;
v1[9999] = 79;
@@ -83,38 +83,38 @@ static inline void TestMappedView2()
BOOST_CHECK(addr == mfh.address());
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);
+ v1 = map_view<int>(mfh);
BOOST_CHECK(v1.size() == 20000);
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
mfh.truncate(2 * 1024 * 1024).value(); // exceed reservation, cause hidden reserve
BOOST_CHECK(addr != nullptr);
- v1 = algorithm::mapped_span<int>(mfh);
+ v1 = map_view<int>(mfh);
BOOST_CHECK(v1.size() == 2 * 1024 * 1024 / sizeof(int));
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
mfh.reserve(2 * 1024 * 1024).value();
BOOST_CHECK(mfh.address() != nullptr);
- v1 = algorithm::mapped_span<int>(mfh);
+ v1 = map_view<int>(mfh);
BOOST_CHECK(v1.size() == 2 * 1024 * 1024 / sizeof(int));
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
mfh.truncate(1 * sizeof(int)).value();
BOOST_CHECK(mfh.address() != nullptr);
- v1 = algorithm::mapped_span<int>(mfh);
+ v1 = map_view<int>(mfh);
BOOST_CHECK(v1.size() == 1);
BOOST_CHECK(v1[0] == 78);
// Use a different handle to extend the file
mapped_file_handle mfh2 = mapped_file_handle::mapped_file(1024 * 1024, {}, "testfile", file_handle::mode::write, file_handle::creation::open_existing, file_handle::caching::all, file_handle::flag::unlink_on_first_close).value();
mfh2.truncate(10000 * sizeof(int)).value();
- v1 = algorithm::mapped_span<int>(mfh2);
+ v1 = map_view<int>(mfh2);
BOOST_CHECK(v1.size() == 10000);
v1[0] = 78;
v1[9999] = 79;
// On Windows this will have updated the mapping, on POSIX it will not, so prod POSIX
mfh.update_map().value();
- v1 = algorithm::mapped_span<int>(mfh);
+ v1 = map_view<int>(mfh);
BOOST_CHECK(v1.size() == 10000);
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
@@ -127,7 +127,7 @@ static inline void TestMappedView2()
fh.truncate(10000 * sizeof(int)).value();
// On POSIX this will have updated the mapping, on Windows it will not, so prod Windows
mfh.update_map().value();
- v1 = algorithm::mapped_span<int>(mfh);
+ v1 = map_view<int>(mfh);
BOOST_REQUIRE(v1.size() == 10000);
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 0);
@@ -136,5 +136,5 @@ static inline void TestMappedView2()
BOOST_CHECK(mfh.address() == nullptr);
}
-KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span1, "Tests that llfio::algorithm::mapped_span works as expected", TestMappedView1())
-KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span2, "Tests that llfio::algorithm::mapped_span works as expected", TestMappedView2())
+KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span1, "Tests that llfio::map_view works as expected", TestMappedView1())
+KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span2, "Tests that llfio::map_view works as expected", TestMappedView2())