Class of an allocator which releases memory only when the allocator is destroyed.
More...
#include <msgpack_light/monotonic_allocator.h>
Class of an allocator which releases memory only when the allocator is destroyed.
Definition at line 35 of file monotonic_allocator.h.
◆ monotonic_allocator() [1/3]
msgpack_light::monotonic_allocator::monotonic_allocator |
( |
| ) |
|
|
inline |
◆ monotonic_allocator() [2/3]
Copy constructor.
- Note
- This simply initialize this instance without any copy.
Definition at line 53 of file monotonic_allocator.h.
◆ monotonic_allocator() [3/3]
Move constructor.
- Parameters
-
[in,out] | other | Instance to move from. |
Definition at line 61 of file monotonic_allocator.h.
◆ ~monotonic_allocator()
msgpack_light::monotonic_allocator::~monotonic_allocator |
( |
| ) |
|
|
inline |
◆ allocate()
void * msgpack_light::monotonic_allocator::allocate |
( |
std::size_t | size, |
|
|
std::size_t | alignment ) |
|
inlinenodiscard |
Allocate memory.
- Parameters
-
[in] | size | Number of bytes to allocate. |
[in] | alignment | Alignment. |
- Returns
- Pointer to the allocated memory.
Definition at line 131 of file monotonic_allocator.h.
◆ allocate_buffer()
void * msgpack_light::monotonic_allocator::allocate_buffer |
( |
std::size_t | size | ) |
|
|
inlinestaticnodiscardprivate |
Allocate a buffer.
- Parameters
-
[in] | size | Size of the buffer. |
- Returns
- Pointer to the allocated buffer.
Definition at line 166 of file monotonic_allocator.h.
◆ allocate_directly()
void * msgpack_light::monotonic_allocator::allocate_directly |
( |
std::size_t | size, |
|
|
std::size_t | alignment ) |
|
inlinenodiscardprivate |
Allocate memory directly using malloc function.
- Parameters
-
[in] | size | Size. |
[in] | alignment | Alignment. |
- Returns
- Pointer to the allocated memory.
Definition at line 229 of file monotonic_allocator.h.
◆ change_buffer()
void msgpack_light::monotonic_allocator::change_buffer |
( |
| ) |
|
|
inlineprivate |
◆ deallocate()
void msgpack_light::monotonic_allocator::deallocate |
( |
void * | ptr | ) |
|
|
inlinenoexcept |
Deallocate memory.
- Note
- This class does nothing in this function.
- Parameters
-
[in] | ptr | Pointer to the deallocated memory. |
Definition at line 154 of file monotonic_allocator.h.
◆ operator=() [1/2]
Copy assignment operator.
- Note
- This does nothing.
- Returns
- This instance after copy.
Definition at line 77 of file monotonic_allocator.h.
◆ operator=() [2/2]
Move assignment operator.
- Parameters
-
[in,out] | other | Instance to move from. |
- Returns
- This instance after move.
Definition at line 88 of file monotonic_allocator.h.
◆ prepare_buffer()
void msgpack_light::monotonic_allocator::prepare_buffer |
( |
| ) |
|
|
inlineprivate |
Prepare a buffer.
- Note
- Call this function after update of current_buffer_size_ to the next size.
Definition at line 193 of file monotonic_allocator.h.
◆ swap()
Swap with another instance.
- Parameters
-
[out] | other | Another instance. |
Definition at line 98 of file monotonic_allocator.h.
◆ try_allocate_from_buffer()
void * msgpack_light::monotonic_allocator::try_allocate_from_buffer |
( |
std::size_t | size, |
|
|
std::size_t | alignment ) |
|
inlinenodiscardprivate |
Try to allocate from the current buffer.
- Parameters
-
[in] | size | Number of bytes to allocate. |
[in] | alignment | Alignment. |
- Returns
- Pointer to the allocated memory. Null on failure.
Definition at line 209 of file monotonic_allocator.h.
◆ current_buffer_
void* msgpack_light::monotonic_allocator::current_buffer_ {nullptr} |
|
private |
◆ current_buffer_size_
◆ initial_buffer_size
std::size_t msgpack_light::monotonic_allocator::initial_buffer_size = 1024U |
|
staticconstexpr |
◆ last_direct_allocation_
void* msgpack_light::monotonic_allocator::last_direct_allocation_ {nullptr} |
|
private |
Last pointer to the memory allocated directly using malloc function.
Definition at line 259 of file monotonic_allocator.h.
◆ max_allocation_from_buffer
std::size_t msgpack_light::monotonic_allocator::max_allocation_from_buffer = 512U |
|
staticconstexpr |
◆ next_allocation_point_
void* msgpack_light::monotonic_allocator::next_allocation_point_ {nullptr} |
|
private |
◆ remaining_buffer_
The documentation for this class was generated from the following file: