mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 16:57:01 +08:00
Move access_mode to page.hpp
This commit is contained in:
parent
873ff4d585
commit
f3b8286c47
@ -21,6 +21,8 @@
|
||||
#ifndef MIO_BASIC_MMAP_HEADER
|
||||
#define MIO_BASIC_MMAP_HEADER
|
||||
|
||||
#include "../page.hpp"
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
@ -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<typename String>
|
||||
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);
|
||||
|
||||
|
||||
@ -22,15 +22,12 @@
|
||||
#define MIO_MMAP_HEADER
|
||||
|
||||
#include "detail/basic_mmap.hpp"
|
||||
#include "page.hpp"
|
||||
|
||||
#include <system_error>
|
||||
|
||||
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;
|
||||
|
||||
@ -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.
|
||||
*
|
||||
|
||||
@ -78,12 +78,12 @@ public:
|
||||
}
|
||||
|
||||
/** Initializes this object with an already established shared mmap. */
|
||||
basic_shared_mmap(std::shared_ptr<mmap_type> mmap) : pimpl_(mmap) {}
|
||||
basic_shared_mmap(std::shared_ptr<mmap_type> mmap) : pimpl_(std::move(mmap)) {}
|
||||
|
||||
/** Initializes this object with an already established shared mmap. */
|
||||
basic_shared_mmap& operator=(std::shared_ptr<mmap_type> mmap)
|
||||
{
|
||||
pimpl_ = mmap;
|
||||
pimpl_ = std::move(mmap);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user