-
Notifications
You must be signed in to change notification settings - Fork 7
shared_memory map
Alairion edited this page May 8, 2021
·
3 revisions
nes::shared_memory ::map, nes::shared_memory ::shared_map
template<typename T>
(1) unique_map_t<T> map(std::uint64_t offset, shared_memory_options options = /*see below*/) const;
template<typename T, typename ValueType = typename std::remove_extent<T>::type>
(2) unique_map_t<T> map(std::uint64_t offset, std::size_t count, shared_memory_options options = /*see below*/) const;
template<typename T>
(3) shared_map_t<T> shared_map(std::uint64_t offset, shared_memory_options options = /*see below*/) const;
template<typename T, typename ValueType = typename std::remove_extent<T>::type>
(4) shared_map_t<T> shared_map(std::uint64_t offset, std::size_t count, shared_memory_options options = /*see below*/) const;
- Maps the shared memory in the process virtual memory. This overload only works if
T
is a trivial type. IfT
is constant,options
value isnes::shared_memory_options::constant
, otherwise it isnes::shared_memory_options::none
. - Maps the shared memory in the process virtual memory. This overload only works if
T
is an unbounded array type, i.e.ValueType[]
, andValueType
is a trivial type. IfValueType
is constant,options
value isnes::shared_memory_options::constant
, otherwise it isnes::shared_memory_options::none
. This overload is useful for compile-time unknown array size. - Same as (1) except that the map is shareable within the calling process.
- Same as (2) except that the map is shareable within the calling process.
Name | Description |
---|---|
offset |
The offset of the map, in bytes, from the start of the shared memory object. |
count |
The number of elements, of type ValueType , to map. |
options |
Additional flags. If it is nes::shared_memory_options::constant then the map is a read-only map so any write operation is the map will lead to an error. You should always set it to nes::shared_memory_options::constant if you don't need to write inside the shared memory. If you give a constant type to the functions, nes::shared_memory_options::constant is the default value of options , otherwise it is nes::shared_memory_options::none . |
- Returns a
nes::unique_map_t<T>
containing the map. - Returns a
nes::unique_map_t<T>
containing the map. Because T is an unbounded array type, thisnes::unique_map_t<T>
defines theoperator[]
overload, and can be used as an array. - Returns a
nes::shared_map_t<T>
that is constructed from the returns of (1). - Returns a
nes::shared_map_t<T>
that is constructed from the returns of (2). Because T is an unbounded array type, thisnes::shared_map_t<T>
defines theoperator[]
overload, and can be used as an array.
*this
must represents a valid shared memory object.
-
offset + sizeof(T)
must be lesser or equals to the size of the shared memory. -
offset + (sizeof(ValueType) * count)
must be lesser or equals to the size of the shared memory - Same as (1).
- Same as (2).
Constant.
May throw a std::runtime_error
if the mapping can not be done.
On Windows, the shared memory is mapped using MapViewOfFile
On Posix systems, the shared memory is mapped using mmap