|
xentara-plugin v2.0.6
The Xentara Plugin Framework
|
A concept used for classes that can be used as memory resources. More...
#include <xentara/memory/MemoryResource.hpp>
Inheritance diagram for xentara::memory::MemoryResource:Classes | |
| class | BlockHandler |
| Base class for handlers that perorm certain operations on a block. More... | |
| class | Handle |
| A handle used to access a memory block within a memory resource. More... | |
Public Types | |
| enum class | HandleRole { Generic , Read , Write } |
| different roles for handles More... | |
| using | BlockHandle = Handle< HandleRole::Generic > |
| A handle used to refer to a memory block. | |
| using | ReadHandle = Handle< HandleRole::Read > |
| A handle used to perform synchronized reads from a memory block. | |
| using | WriteHandle = Handle< HandleRole::Write > |
| A handle used to perform synchronized writed to a memory block. | |
Public Member Functions | |
| virtual | ~MemoryResource ()=0 |
| Virtual destructor. | |
Creating and Destroying Memory Blocks | |
| auto | createBlock (std::reference_wrapper< const BlockHandler > handler) -> std::pair< BlockHandle, void * > |
| Creates a memory block. | |
| auto | destroyBlock (const BlockHandle &blockHandle) noexcept -> void |
| Destroys a memory block. | |
| auto | placement (const BlockHandle &blockHandle) const noexcept -> void * |
| Recovers the current placement of a memory block without synchronization. | |
Reading from Memory Blocks | |
| auto | beginRead (const BlockHandle &blockHandle) -> std::pair< ReadHandle, const void * > |
| Locks a handle for reading. | |
| auto | endRead (const BlockHandle &blockHandle, const ReadHandle &readHandle) noexcept -> void |
| Unlocks a handle for reading. | |
Writing to Memory Blocks | |
| auto | beginWrite (const BlockHandle &blockHandle, bool copy) -> std::pair< WriteHandle, void * > |
| Locks a handle for writing. | |
| auto | discard (const BlockHandle &blockHandle, const WriteHandle &writeHandle) noexcept -> void |
| Unlocks a handle for writing, discarding the data if possible. | |
| auto | commit (const BlockHandle &blockHandle, const WriteHandle &writeHandle, std::chrono::system_clock::time_point timeStamp, std::span< std::reference_wrapper< const process::Event > > additionalEvents={}) -> void |
| Unlocks a handle for writing, commiting the data if necessary. | |
A concept used for classes that can be used as memory resources.
A handle used to refer to a memory block.
A handle used to perform synchronized reads from a memory block.
A handle used to perform synchronized writed to a memory block.
|
strong |
|
pure virtualdefault |
Virtual destructor.
| auto xentara::memory::MemoryResource::beginRead | ( | const BlockHandle & | blockHandle | ) | -> std::pair< ReadHandle, const void * > |
Locks a handle for reading.
| blockHandle | A handle to the block to lock. |
| auto xentara::memory::MemoryResource::beginWrite | ( | const BlockHandle & | blockHandle, |
| bool | copy | ||
| ) | -> std::pair< WriteHandle, void * > |
Locks a handle for writing.
| blockHandle | A handle to the block to lock. |
| copy | Whether the data of the existing block should be copied to the newly created swap-in block. If you pass true, the new block will contain a copy of the old block; if you pass false, then the new block will be default constructed. |
| auto xentara::memory::MemoryResource::commit | ( | const BlockHandle & | blockHandle, |
| const WriteHandle & | writeHandle, | ||
| std::chrono::system_clock::time_point | timeStamp, | ||
| std::span< std::reference_wrapper< const process::Event > > | additionalEvents = {} |
||
| ) | -> void |
Unlocks a handle for writing, commiting the data if necessary.
This function atomically replaces the existing block with the swap-in block allocated in beginWrite().
| blockHandle | A handle to the block to unlock. |
| writeHandle | The read handle returned by beginWrite() when the block was locked. |
| timeStamp | The time stamp to be used when raising change events. |
| additionalEvents | Additional events to raise together with the change events. |
| auto xentara::memory::MemoryResource::createBlock | ( | std::reference_wrapper< const BlockHandler > | handler | ) | -> std::pair< BlockHandle, void * > |
Creates a memory block.
This function allocates memory for the block and then calls BlockHandler::constructAt(void *placement) const to construct a blockin the allocated space.
| handler | The handler for the block. Must remain valid until destroyBlock() is called. |
| std::bad_alloc | The memory resource is exhausted |
|
noexcept |
Destroys a memory block.
This function calls BlockHandler::destroy() to destroy the block, and then deallocates the data.
| blockHandle | A handle to the block. This must be a handle previously returned by allocate(). |
|
noexcept |
Unlocks a handle for writing, discarding the data if possible.
This function will discard the swap-in block allocated in beginWrite() and the old block will be retained.
| blockHandle | A handle to the block to unlock. |
| writeHandle | The read handle returned by beginWrite() when the block was locked. |
|
noexcept |
Unlocks a handle for reading.
| blockHandle | A handle to the block to unlock. |
| readHandle | The read handle returned by beginRead() when the block was locked. |
|
noexcept |
Recovers the current placement of a memory block without synchronization.
| blockHandle | A handle to the block. This must be a handle previously returned by allocate(). |