LLFIO
v2.00
|
Provides an owning, typed view of memory mapped from a section_handle
or a file_handle
suitable for feeding to STL algorithms or the Ranges TS.
More...
#include "mapped.hpp"
Public Types | |
using | extent_type = typename section_handle::extent_type |
The extent type. | |
using | size_type = typename section_handle::size_type |
The size type. | |
using | element_type = typename span< T >::element_type |
The index type. More... | |
using | value_type = typename span< T >::value_type |
The value type. | |
using | reference = typename span< T >::reference |
The reference type. | |
using | pointer = typename span< T >::pointer |
The pointer type. | |
using | const_reference = typename span< T >::const_reference |
The const reference type. | |
using | const_pointer = typename span< T >::const_pointer |
The const pointer type. | |
using | iterator = typename span< T >::iterator |
The iterator type. | |
using | reverse_iterator = typename span< T >::reverse_iterator |
The const iterator type. More... | |
using | difference_type = typename span< T >::difference_type |
The const reverse iterator type. More... | |
Public Member Functions | |
constexpr | mapped () |
Default constructor. | |
mapped (const mapped &)=delete | |
mapped (mapped &&o) noexcept | |
mapped & | operator= (const mapped &)=delete |
mapped & | operator= (mapped &&o) noexcept |
~mapped () | |
Detaches the array of T , before tearing down the map. | |
const section_handle & | section () const noexcept |
Returns a reference to the internal section handle. | |
const map_handle & | map () const noexcept |
Returns a reference to the internal map handle. | |
span< T > | as_span () const noexcept |
Returns a span referring to this mapped region. | |
mapped (size_type length, bool zeroed=false, section_handle::flag _flag=section_handle::flag::readwrite) | |
mapped (section_handle &sh, size_type length=(size_type) -1, extent_type byteoffset=0, section_handle::flag _flag=section_handle::flag::readwrite) | |
mapped (file_handle &backing, size_type length=(size_type) -1, extent_type maximum_size=0, extent_type byteoffset=0, section_handle::flag _flag=section_handle::flag::readwrite) | |
Provides an owning, typed view of memory mapped from a section_handle
or a file_handle
suitable for feeding to STL algorithms or the Ranges TS.
This opens a new map_handle
(and if necessary a section_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.
The array of objects upon which the owning view is opened is attached via in_place_detach<T>()
in the mapped
constructor. In the final destructor (i.e. not the destructor of any moved-from instances), the array of objects is detached via in_place_detach<T>()
just before the map_handle
is destroyed. As it is illegal to attach objects into more than one address or process at a time, you must not call mapped
on objects already mapped into any process anywhere else.
These owning semantics are convenient, but may be too heavy for your use case. You can gain more fine grained control using map_handle
/mapped_file_handle
directly with P1631 attached<T>
.
mapped
actually use P1631 in_place_attach/in_place_detach, as currently GCC and MSVC do two memcpy's of the mapped region. Also, we restrict the use of in_place_attach/in_place_detach to regions less than 4Kb in size, as even clang falls down on large regions.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 this to storage before the destructor returns.
using llfio_v2_xxx::mapped< T >::difference_type = typename span<T>::difference_type |
The const reverse iterator type.
The difference type
using llfio_v2_xxx::mapped< T >::element_type = typename span<T>::element_type |
The index type.
The element type
using llfio_v2_xxx::mapped< T >::reverse_iterator = typename span<T>::reverse_iterator |
The const iterator type.
The reverse iterator type
|
inlineexplicit |
Create a view of newly allocated unused memory, creating new memory if insufficient unused memory is available. Note that the memory mapped by this call may contain non-zero bits (recycled memory) unless zeroed
is true.
length | The number of items to map. |
zeroed | Whether to ensure that the viewed memory returned is all bits zero or not. |
_flag | The flags to pass to map_handle::map() . |
|
inlineexplicit |
Construct a mapped view of the given section handle.
sh | The section handle to use as the data source for creating the map. |
length | The number of items to map, use -1 to mean the length of the section handle divided by sizeof(T) . |
byteoffset | The byte offset into the section handle, this does not need to be a multiple of the page size. |
_flag | The flags to pass to map_handle::map() . |
|
inlineexplicit |
Construct a mapped view of the given file.
backing | The handle to use as backing storage. |
length | The number of items to map, use -1 to mean the length of the section handle divided by sizeof(T) . |
maximum_size | The initial size of this section in bytes, which cannot be larger than any backing file. Zero means to use backing.maximum_extent() . |
byteoffset | The byte offset into the section handle, this does not need to be a multiple of the page size. |
_flag | The flags to pass to map_handle::map() . |