From f3b8286c479218ea71bb3012ffc7cc4c3d142d9e Mon Sep 17 00:00:00 2001 From: mandreyel Date: Fri, 27 Jul 2018 21:47:52 +0200 Subject: [PATCH] Move access_mode to page.hpp --- include/mio/detail/basic_mmap.hpp | 12 ++++-------- include/mio/mmap.hpp | 5 +---- include/mio/page.hpp | 10 ++++++++++ include/mio/shared_mmap.hpp | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/mio/detail/basic_mmap.hpp b/include/mio/detail/basic_mmap.hpp index c4be177..f5d3303 100644 --- a/include/mio/detail/basic_mmap.hpp +++ b/include/mio/detail/basic_mmap.hpp @@ -21,6 +21,8 @@ #ifndef MIO_BASIC_MMAP_HEADER #define MIO_BASIC_MMAP_HEADER +#include "../page.hpp" + #include #include #include @@ -39,12 +41,6 @@ namespace detail { enum { map_entire_file = 0 }; -enum class access_mode -{ - read, - write -}; - #ifdef _WIN32 using file_handle_type = HANDLE; #else @@ -135,9 +131,9 @@ public: template void map(String& path, size_type offset, size_type length, - access_mode mode, std::error_code& error); + access_mode mode, std::error_code& error); void map(handle_type handle, size_type offset, size_type length, - access_mode mode, std::error_code& error); + access_mode mode, std::error_code& error); void unmap(); void sync(std::error_code& error); diff --git a/include/mio/mmap.hpp b/include/mio/mmap.hpp index 7c1b0be..b1539ce 100644 --- a/include/mio/mmap.hpp +++ b/include/mio/mmap.hpp @@ -22,15 +22,12 @@ #define MIO_MMAP_HEADER #include "detail/basic_mmap.hpp" +#include "page.hpp" #include namespace mio { -// This is used by basic_mmap to determine whether to create a read-only or a read-write -// memory mapping. The two possible values are `read` and `write`. -using detail::access_mode; - // This value may be provided as the `length` parameter to the constructor or // `map`, in which case a memory mapping of the entire file is created. using detail::map_entire_file; diff --git a/include/mio/page.hpp b/include/mio/page.hpp index c5a73b4..c2536a0 100644 --- a/include/mio/page.hpp +++ b/include/mio/page.hpp @@ -32,6 +32,16 @@ namespace mio { +/** + * This is used by `basic_mmap` to determine whether to create a read-only or + * a read-write memory mapping. + */ +enum class access_mode +{ + read, + write +}; + /** * Determines the operating system's page allocation granularity. * diff --git a/include/mio/shared_mmap.hpp b/include/mio/shared_mmap.hpp index d1a4a2e..015f7d5 100644 --- a/include/mio/shared_mmap.hpp +++ b/include/mio/shared_mmap.hpp @@ -78,12 +78,12 @@ public: } /** Initializes this object with an already established shared mmap. */ - basic_shared_mmap(std::shared_ptr mmap) : pimpl_(mmap) {} + basic_shared_mmap(std::shared_ptr mmap) : pimpl_(std::move(mmap)) {} /** Initializes this object with an already established shared mmap. */ basic_shared_mmap& operator=(std::shared_ptr mmap) { - pimpl_ = mmap; + pimpl_ = std::move(mmap); return *this; }