|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Variable-size pool that owns its storage: no heap and no separately declared, possibly misaligned buffer. More...
#include <stk_memory_bytepool.h>
Public Member Functions | |
| StaticBytePool (const char *name=nullptr) | |
| STK_STATIC_ASSERT_DESC ((BLOCK_ALIGN >=4U) &&((BLOCK_ALIGN &(BLOCK_ALIGN - 1U))==0U), "STK_MEMORY_BYTEPOOL_ALIGN_DEFAULT must be a power of two not less than 4") | |
| EWaitResult | TimedAllocEx (void **block, size_t size, Timeout timeout_ticks=WAIT_INFINITE) |
| Allocate a block, preserving the full wait outcome. | |
| void * | TimedAlloc (size_t size, Timeout timeout_ticks=WAIT_INFINITE) |
| Allocate a block, blocking until memory becomes available or the timeout expires. | |
| template<typename T> | |
| T * | TimedAllocT (Timeout timeout_ticks=WAIT_INFINITE) |
| Allocate one typed block, blocking until memory becomes available or the timeout expires. | |
| void * | Alloc (size_t size) |
| Allocate a block, blocking indefinitely until memory is available. | |
| template<typename T> | |
| T * | AllocT () |
| Allocate one typed block, blocking indefinitely until memory is available. | |
| void * | TryAlloc (size_t size) |
| Non-blocking allocation attempt. | |
| template<typename T> | |
| T * | TryAllocT () |
| Non-blocking typed allocation attempt. | |
| template<typename T, typename... TArgs> | |
| T * | TimedNewT (Timeout timeout_ticks, TArgs &&...args) |
Allocate a block for a T and construct it (placement new), waiting up to timeout_ticks. | |
| template<typename T, typename... TArgs> | |
| T * | NewT (TArgs &&...args) |
Allocate a block for a T and construct it, blocking indefinitely. | |
| template<typename T, typename... TArgs> | |
| T * | TryNewT (TArgs &&...args) |
Non-blocking TimedNewT(). ISR-safe if the constructor of T is. | |
| template<typename T> | |
| void | DeleteT (T *ptr) |
| Destroy an object created with the NewT() family and return its block to the pool. | |
| template<typename T, typename... TArgs> | |
| PoolPtr< T, BytePool > | TryMakeT (TArgs &&...args) |
| Non-blocking allocate-and-construct returning an owning PoolPtr. | |
| template<typename T, typename... TArgs> | |
| PoolPtr< T, BytePool > | MakeT (TArgs &&...args) |
| Blocking allocate-and-construct returning an owning PoolPtr. | |
| bool | Free (void *ptr) |
| Return a previously allocated block to the pool. | |
| void | GetInfo (size_t &available, size_t &largest, size_t &fragments) const |
| Collect pool statistics. | |
| MemoryAllocator::Stats | GetStats () const |
| Get a consistent O(1) statistics snapshot in the same format as MemoryAllocator::GetStats(). | |
| size_t | GetMaxScanLength () const |
| Get the length of the longest block-list walk (in blocks) of any allocation so far. | |
| size_t | GetAllocFailCount () const |
Get the number of allocation requests that failed because no suitable block was available (timeouts, NO_WAIT misses and requests larger than GetMaxRequest()). | |
| size_t | GetPeakUsedSize () const |
| Get the high watermark of pool consumption in bytes (headers included). | |
| bool | IsStorageValid () const |
| Verify that the backing storage is valid and the pool is ready for use. | |
| size_t | GetSize () const |
| Get the total size of the managed (aligned) area in bytes, headers included. | |
| size_t | GetMaxRequest () const |
| Get the largest request that can ever succeed on this pool. | |
| void | SetTraceName (const char *name) |
| Set name. | |
| const char * | GetTraceName () const |
| Get name. | |
Static Public Member Functions | |
| static constexpr size_t | AlignSize (size_t raw_size) |
Round a size up to the nearest multiple of the block alignment (BLOCK_ALIGN). | |
| static constexpr size_t | RequiredSize (size_t payload_size) |
| Compute the pool space consumed by a single allocation of payload_size bytes. | |
Static Public Attributes | |
| static const size_t | BLOCK_ALIGN = stk::memory::MemoryAllocator::MIN_ALIGNMENT |
| Payload alignment and block size granularity in bytes. | |
| static const size_t | HEADER_SIZE = ((BLOCK_ALIGN > 8U) ? BLOCK_ALIGN : 8U) |
Size of the per-block header in bytes: max(8, BLOCK_ALIGN). | |
Private Member Functions | |
| STK_STATIC_ASSERT_DESC (TSize >=(BytePool::HEADER_SIZE+BytePool::BLOCK_ALIGN), "pool size must fit at least one block") | |
| STK_STATIC_ASSERT_DESC (TSize<=(0xFFFFFFFFUL &~(BytePool::BLOCK_ALIGN - 1U)), "pool size exceeds the 32-bit block size limit") | |
| STK_NONCOPYABLE_CLASS (BytePool) | |
| void | Init () |
| Align the area and create the initial single free block. | |
| bool | IsSane (const BlockHeader *h) const |
| Check that the header h (which must be inside the pool) looks intact. | |
| void | Coalesce (BlockHeader *h) |
| Merge h (a free block) with the free blocks that directly follow it. | |
| void * | FindFree (size_t need) |
| Find (and claim) the first free block that can hold need bytes. | |
| void * | ScanRange (BlockHeader *from, const BlockHeader *stop, size_t need, size_t &scanned) |
| Scan the blocks in [from, stop) for a free block that can hold need bytes. | |
| bool | IsBlockStart (const BlockHeader *h) const |
| Check that h is the header of an existing block (walks the list from the start). | |
Static Private Member Functions | |
| static size_t | HeapSize (size_t size) |
| Size of the heap buffer for size usable bytes: adds slack for aligning the area start when BLOCK_ALIGN is stricter than the guarantee of MemoryAllocator::Allocate(). 0 on overflow. | |
| static BlockHeader * | Next (const BlockHeader *h) |
| Get the header of the block that follows h. | |
| static uint32_t * | GuardOf (const BlockHeader *h) |
| Get the guard word location of the used block h (its last 4 bytes). | |
| static __stk_forceinline void | Fill (void *ptr, size_t size, uint8_t value) |
| Fill size bytes at ptr with value (used by diagnostics only). | |
| static void | AccountRun (size_t run, size_t &available, size_t &largest, size_t &fragments) |
| Add one free run of run bytes (headers included) to the statistics. | |
Private Attributes | |
| uint8_t | m_buf [TSize] |
| uint8_t * | m_storage |
| raw storage as supplied or allocated (before alignment) | |
| BlockHeader * | m_first |
| first block header (aligned), nullptr if the pool is invalid | |
| BlockHeader * | m_end |
| one past the last block (aligned), nullptr if the pool is invalid | |
| BlockHeader * | m_rover |
| where the next search starts (STK_MEMORY_BYTEPOOL_NEXT_FIT) | |
| sync::ConditionVariable | m_cv |
| signalled by Free() to wake tasks blocked in TimedAlloc() | |
| size_t | m_storage_size |
| size of the raw storage in bytes | |
| MemoryAllocator::Stats | m_stats |
| live statistics: bytes of used blocks (headers included), watermark, counters | |
| size_t | m_max_scan |
| longest block-list walk of a single allocation | |
| bool | m_storage_owned |
| true -> storage is heap-allocated; free in destructor | |
Static Private Attributes | |
| static const size_t | MIN_BLOCK_SIZE = (HEADER_SIZE + BLOCK_ALIGN) |
Smallest block: a header plus the minimum payload (BLOCK_ALIGN). | |
| static const size_t | POOL_SIZE_MAX = (static_cast<size_t>(0xFFFFFFFFUL) & ~(BLOCK_ALIGN - 1U)) |
| Largest managed area: block sizes are stored as 32-bit values (kept a multiple of BLOCK_ALIGN). | |
| static const size_t | GUARD_SIZE = (( (0) != 0) ? 4U : 0U) |
| Size of the overrun guard word at the end of every used block (0 = disabled). | |
| static const uint32_t | GUARD_MAGIC = 0xA5C3E17BUL |
| value of the guard word of a used block | |
| static const uint32_t | STATE_FREE = 0x46524545UL |
| "FREE" | |
| static const uint32_t | STATE_USED = 0x55534544UL |
| "USED" | |
| static const uint32_t | STATE_NONE = 0x00000000UL |
| stale header absorbed by a merge | |
| static const uint8_t | FILL_ALLOC = 0xCDU |
| payload fill on allocation (STK_MEMORY_POOL_CHECKS) | |
| static const uint8_t | FILL_FREE = 0xDDU |
| payload fill on free (STK_MEMORY_POOL_CHECKS) | |
Variable-size pool that owns its storage: no heap and no separately declared, possibly misaligned buffer.
| TSize | Size of the managed area in bytes (headers included). Use BytePool::RequiredSize() to compute it from the blocks that must live at the same time. stk::memory::StaticBytePool<4096> g_Pool("msgs");
Variable-size pool that owns its storage: no heap and no separately declared, possibly misaligned buf... Definition stk_memory_bytepool.h:1187 |
Definition at line 1185 of file stk_memory_bytepool.h.
|
inlineexplicit |
Definition at line 1192 of file stk_memory_bytepool.h.
References stk::memory::BytePool::BytePool(), and stk::memory::detail::BytePoolStorage< TSize >::m_buf.
|
inlinestaticprivateinherited |
Add one free run of run bytes (headers included) to the statistics.
Definition at line 1140 of file stk_memory_bytepool.h.
References HEADER_SIZE.
Referenced by GetInfo().
|
inlinestaticconstexprinherited |
Round a size up to the nearest multiple of the block alignment (BLOCK_ALIGN).
| [in] | raw_size | Size in bytes. |
Definition at line 219 of file stk_memory_bytepool.h.
References BLOCK_ALIGN.
Referenced by Init(), RequiredSize(), and STK_STATIC_ASSERT_DESC().
|
inlineinherited |
Allocate a block, blocking indefinitely until memory is available.
| [in] | size | Requested payload size in bytes. |
nullptr only if the wait was cancelled via IKernel::CancelTaskWait() or the request is invalid (never on timeout). Use TimedAllocEx() to tell these apart. Definition at line 757 of file stk_memory_bytepool.h.
References TimedAlloc(), and stk::WAIT_INFINITE.
Referenced by stk_bytepool_alloc().
|
inlineinherited |
Allocate one typed block, blocking indefinitely until memory is available.
nullptr (see Alloc()). Definition at line 763 of file stk_memory_bytepool.h.
References TimedAllocT(), and stk::WAIT_INFINITE.
|
inlineprivateinherited |
Merge h (a free block) with the free blocks that directly follow it.
Definition at line 1020 of file stk_memory_bytepool.h.
References IsSane(), m_end, m_rover, Next(), stk::memory::BytePool::BlockHeader::size, STATE_FREE, and STATE_NONE.
Referenced by Free(), and ScanRange().
|
inlineinherited |
Destroy an object created with the NewT() family and return its block to the pool.
| [in] | ptr | Object pointer, nullptr is allowed and results in noop. |
T is. Definition at line 812 of file stk_memory_bytepool.h.
References Free(), and STK_UNUSED.
|
inlinestaticprivateinherited |
Fill size bytes at ptr with value (used by diagnostics only).
Definition at line 506 of file stk_memory_bytepool.h.
References __stk_forceinline, and stk::STK_MEMSET().
Referenced by Free(), and ScanRange().
|
inlineprivateinherited |
Find (and claim) the first free block that can hold need bytes.
| [in] | need | Total block size including header (already aligned). |
nullptr if no free block is large enough. Definition at line 1098 of file stk_memory_bytepool.h.
References m_end, m_first, m_max_scan, m_rover, and ScanRange().
Referenced by TimedAllocEx().
|
inlineinherited |
Return a previously allocated block to the pool.
Marks the block free, merges it with the free blocks that follow it and wakes all tasks blocked inside Alloc() or TimedAlloc() so each can re-check its own request. A woken task may find that the memory was taken by a racing TryAlloc() and continue waiting.
| [in] | ptr | Pointer previously returned by an allocation function of this pool instance. Must not be nullptr. Range, alignment and the block state marker are validated (plus the guard word with STK_MEMORY_BYTEPOOL_GUARD); failures trigger an assertion in debug builds and return false in release builds. With STK_MEMORY_POOL_CHECKS the pointer is additionally verified to be the start of a real block. |
true - block successfully returned. false - ptr is nullptr, does not belong to this pool, is misaligned, the block is not in use (double-free) or its guard word was overwritten; each case indicates a caller logic error. TryAlloc()). Free(). Definition at line 841 of file stk_memory_bytepool.h.
References BLOCK_ALIGN, Coalesce(), Fill(), FILL_FREE, GUARD_MAGIC, GuardOf(), HEADER_SIZE, IsBlockStart(), IsSane(), m_cv, m_end, m_first, m_stats, stk::hw::PtrToWord(), stk::memory::BytePool::BlockHeader::size, stk::memory::BytePool::BlockHeader::state, STATE_FREE, STATE_USED, and STK_ASSERT.
Referenced by DeleteT(), stk::memory::MemoryAllocator::Weak::Free(), and stk_bytepool_free().
|
inlineinherited |
Get the number of allocation requests that failed because no suitable block was available (timeouts, NO_WAIT misses and requests larger than GetMaxRequest()).
size_t read is a single instruction. Definition at line 401 of file stk_memory_bytepool.h.
References m_stats.
Referenced by stk_bytepool_get_alloc_fail_count().
|
inlineinherited |
Collect pool statistics.
Walks the block list under a critical section, so the three values are mutually consistent. Adjacent free blocks are counted as one fragment.
| [out] | available | Total payload bytes that can still be allocated, summed over all free fragments (a single request can use at most largest of them). |
| [out] | largest | Payload size of the largest free fragment, i.e. the biggest request that would succeed right now (less the guard word with STK_MEMORY_BYTEPOOL_GUARD). |
| [out] | fragments | Number of free fragments (1 means no external fragmentation). |
GetStats() for an O(1) alternative. Definition at line 928 of file stk_memory_bytepool.h.
References AccountRun(), IsSane(), m_end, m_first, Next(), STATE_FREE, and STK_ASSERT.
Referenced by stk_bytepool_get_info().
|
inlineinherited |
Get the largest request that can ever succeed on this pool.
Equals the payload of a single block spanning the entire pool (less the guard word with STK_MEMORY_BYTEPOOL_GUARD).
Definition at line 433 of file stk_memory_bytepool.h.
References GetSize(), GUARD_SIZE, HEADER_SIZE, and MIN_BLOCK_SIZE.
Referenced by stk_bytepool_get_max_request(), and TimedAllocEx().
|
inlineinherited |
Get the length of the longest block-list walk (in blocks) of any allocation so far.
The walk is executed inside the critical section, so this is a direct measure of the worst-case time interrupts/scheduling were blocked by the allocator (multiply by the cost of one iteration of your target). Use it to decide whether a time-critical ISR may call TryAlloc().
size_t read is a single instruction. Definition at line 395 of file stk_memory_bytepool.h.
References m_max_scan.
Referenced by stk_bytepool_get_max_scan_length().
|
inlineinherited |
Get the high watermark of pool consumption in bytes (headers included).
size_t read is a single instruction. Definition at line 406 of file stk_memory_bytepool.h.
References m_stats.
Referenced by stk_bytepool_get_peak_used_size().
|
inlineinherited |
Get the total size of the managed (aligned) area in bytes, headers included.
Definition at line 421 of file stk_memory_bytepool.h.
References m_end, and m_first.
Referenced by GetMaxRequest(), and stk_bytepool_get_size().
|
inlineinherited |
Get a consistent O(1) statistics snapshot in the same format as MemoryAllocator::GetStats().
capacity is the managed area size and allocated the bytes held by used blocks, both including headers (i.e. the real pool consumption). min_ever_free is derived from the peak, so it is exact in terms of consumed bytes, not of allocatable payload.
Definition at line 963 of file stk_memory_bytepool.h.
References m_stats.
Referenced by stk::memory::MemoryAllocator::Weak::GetStats(), and stk_bytepool_get_stats().
|
inlineinherited |
Get name.
NULL if not set or if STK_SYNC_DEBUG_NAMES is 0. Definition at line 629 of file stk_common.h.
|
inlinestaticprivateinherited |
Get the guard word location of the used block h (its last 4 bytes).
Definition at line 499 of file stk_memory_bytepool.h.
References stk::memory::BytePool::BlockHeader::size.
Referenced by Free(), and ScanRange().
|
inlinestaticprivateinherited |
Size of the heap buffer for size usable bytes: adds slack for aligning the area start when BLOCK_ALIGN is stricter than the guarantee of MemoryAllocator::Allocate(). 0 on overflow.
Definition at line 477 of file stk_memory_bytepool.h.
References BLOCK_ALIGN, and stk::memory::MemoryAllocator::MIN_ALIGNMENT.
Referenced by BytePool().
|
inlineprivateinherited |
Align the area and create the initial single free block.
m_first and m_end as nullptr if the area is unusable. Definition at line 974 of file stk_memory_bytepool.h.
References AlignSize(), BLOCK_ALIGN, HEADER_SIZE, m_end, m_first, m_rover, m_stats, m_storage, m_storage_size, MIN_BLOCK_SIZE, POOL_SIZE_MAX, stk::hw::PtrToWord(), STATE_FREE, STK_STATIC_ASSERT_DESC, and stk::hw::WordToPtr().
Referenced by BytePool(), and BytePool().
|
inlineprivateinherited |
Check that h is the header of an existing block (walks the list from the start).
Definition at line 1124 of file stk_memory_bytepool.h.
References IsSane(), m_end, m_first, and Next().
Referenced by Free().
|
inlineprivateinherited |
Check that the header h (which must be inside the pool) looks intact.
Verifies the state marker, the size granularity and that the block does not extend beyond the pool end. Protects the list walkers from endless loops and out-of-bounds reads if a caller overruns a payload.
Definition at line 1010 of file stk_memory_bytepool.h.
References BLOCK_ALIGN, m_end, MIN_BLOCK_SIZE, stk::memory::BytePool::BlockHeader::size, stk::memory::BytePool::BlockHeader::state, STATE_FREE, and STATE_USED.
Referenced by Coalesce(), Free(), GetInfo(), IsBlockStart(), and ScanRange().
|
inlineinherited |
Verify that the backing storage is valid and the pool is ready for use.
Always true for pools constructed with sufficiently large external storage. For heap-constructed pools, false if the allocation failed. false as well if the supplied area is too small to hold even a single block.
true if the pool is ready for use. Definition at line 415 of file stk_memory_bytepool.h.
References m_first.
Referenced by stk_bytepool_is_storage_valid(), and TimedAllocEx().
|
inlineinherited |
Blocking allocate-and-construct returning an owning PoolPtr.
Definition at line 830 of file stk_memory_bytepool.h.
References NewT().
|
inlineinherited |
Allocate a block for a T and construct it, blocking indefinitely.
Definition at line 800 of file stk_memory_bytepool.h.
References TimedNewT(), and stk::WAIT_INFINITE.
Referenced by MakeT().
|
inlinestaticprivateinherited |
Get the header of the block that follows h.
m_end, which must not be dereferenced. Definition at line 492 of file stk_memory_bytepool.h.
References stk::memory::BytePool::BlockHeader::size.
Referenced by Coalesce(), GetInfo(), IsBlockStart(), and ScanRange().
|
inlinestaticconstexprinherited |
Compute the pool space consumed by a single allocation of payload_size bytes.
Equals the aligned payload (plus the guard word if STK_MEMORY_BYTEPOOL_GUARD is 1) plus the block header. Use it to size external storage, adding the value for every block that must be alive at the same time:
| [in] | payload_size | Requested payload size in bytes. |
Definition at line 234 of file stk_memory_bytepool.h.
References AlignSize(), GUARD_SIZE, and HEADER_SIZE.
Referenced by STK_STATIC_ASSERT_DESC(), TimedAllocEx(), and tx_byte_pool_create().
|
inlineprivateinherited |
Scan the blocks in [from, stop) for a free block that can hold need bytes.
| [in,out] | scanned | Incremented for every inspected block. |
Definition at line 1040 of file stk_memory_bytepool.h.
References Coalesce(), Fill(), FILL_ALLOC, GUARD_MAGIC, GUARD_SIZE, GuardOf(), HEADER_SIZE, IsSane(), m_end, m_first, m_rover, m_stats, MIN_BLOCK_SIZE, Next(), stk::memory::BytePool::BlockHeader::size, stk::memory::BytePool::BlockHeader::state, STATE_FREE, STATE_USED, and STK_ASSERT.
Referenced by FindFree().
|
inlineinherited |
Set name.
| [in] | name | Null-terminated string or NULL. |
Definition at line 617 of file stk_common.h.
References STK_UNUSED.
Referenced by stk::memory::BlockMemoryPool::BlockMemoryPool(), stk::memory::BlockMemoryPool::BlockMemoryPool(), stk::memory::BytePool::BytePool(), stk::memory::BytePool::BytePool(), RunExample(), tx_block_pool_create(), tx_mutex_create(), and tx_queue_create().
|
privateinherited |
|
inherited |
References BLOCK_ALIGN.
|
private |
References stk::memory::BytePool::BLOCK_ALIGN, and stk::memory::BytePool::HEADER_SIZE.
|
private |
References stk::memory::BytePool::BLOCK_ALIGN.
|
inlineinherited |
Allocate a block, blocking until memory becomes available or the timeout expires.
| [in] | size | Requested payload size in bytes. |
| [in] | timeout_ticks | Maximum time to wait (ticks). Same semantics as TimedAllocEx(). |
BLOCK_ALIGN, or nullptr on timeout, cancellation or invalid arguments. TimedAllocEx() to tell them apart. NO_WAIT; ISR-unsafe otherwise. Definition at line 737 of file stk_memory_bytepool.h.
References TimedAllocEx(), and stk::WAIT_RESULT_SIGNAL.
Referenced by Alloc(), stk_bytepool_timed_alloc(), TimedAllocT(), and TryAlloc().
|
inlineinherited |
Allocate a block, preserving the full wait outcome.
Searches for a free block of at least size bytes. If none exists the calling task is suspended via the internal ConditionVariable and re-tries after every Free() until the request is satisfied, the timeout expires or the wait is cancelled. The timeout is a total budget, not per wake-up.
| [out] | block | Receives the allocated block on WAIT_RESULT_SIGNAL, nullptr on any other result. Must not be nullptr. |
| [in] | size | Requested payload size in bytes (must be > 0 and <= GetMaxRequest()). |
| [in] | timeout_ticks | Maximum time to wait (ticks). WAIT_INFINITE - block indefinitely (default). NO_WAIT - fail immediately if no suitable block exists (ISR-safe). |
WAIT_RESULT_SIGNAL - a block was allocated (immediately or after waiting), WAIT_RESULT_TIMEOUT - no suitable block became available before the timeout (or NO_WAIT was passed); a block freed at the very moment the timeout expired is still returned as SIGNAL, WAIT_RESULT_CANCELED - the wait was cancelled via IKernel::CancelTaskWait(), WAIT_RESULT_FAIL - invalid arguments (block is nullptr, size is 0 or exceeds GetMaxRequest(), no valid storage) or the kernel rejected the wait. NO_WAIT; ISR-unsafe otherwise. Definition at line 630 of file stk_memory_bytepool.h.
References FindFree(), GetMaxRequest(), stk::GetTicks(), stk::hw::IsInsideISR(), IsStorageValid(), m_cv, m_stats, stk::NO_WAIT, RequiredSize(), STK_ASSERT, stk::WAIT_INFINITE, stk::WAIT_RESULT_FAIL, stk::WAIT_RESULT_SIGNAL, and stk::WAIT_RESULT_TIMEOUT.
Referenced by stk_bytepool_timed_alloc_ex(), and TimedAlloc().
|
inlineinherited |
Allocate one typed block, blocking until memory becomes available or the timeout expires.
Thin typed wrapper around TimedAlloc() for sizeof(T) bytes. The memory is uninitialized; no constructor is run (see TimedNewT()). T must not require alignment above BLOCK_ALIGN (compile-time checked).
| [in] | timeout_ticks | Maximum time to wait (ticks). |
nullptr if the timeout expired. NO_WAIT; ISR-unsafe otherwise. Definition at line 750 of file stk_memory_bytepool.h.
References BLOCK_ALIGN, STK_STATIC_ASSERT_DESC, and TimedAlloc().
Referenced by AllocT(), TimedNewT(), and TryAllocT().
|
inlineinherited |
Allocate a block for a T and construct it (placement new), waiting up to timeout_ticks.
| [in] | timeout_ticks | Maximum time to wait (ticks). |
| [in] | args | Constructor arguments forwarded to T. |
nullptr. DeleteT(). ISR-safe only with NO_WAIT (and only if the constructor is). Definition at line 786 of file stk_memory_bytepool.h.
References STK_UNUSED, and TimedAllocT().
Referenced by NewT(), and TryNewT().
|
inlineinherited |
Non-blocking allocation attempt.
| [in] | size | Requested payload size in bytes. |
nullptr if no suitable free block exists. Definition at line 768 of file stk_memory_bytepool.h.
References stk::NO_WAIT, and TimedAlloc().
Referenced by stk::memory::MemoryAllocator::Weak::Allocate(), and stk_bytepool_try_alloc().
|
inlineinherited |
Non-blocking typed allocation attempt.
nullptr if no suitable free block exists. TryAlloc()). Definition at line 774 of file stk_memory_bytepool.h.
References stk::NO_WAIT, and TimedAllocT().
|
inlineinherited |
Non-blocking allocate-and-construct returning an owning PoolPtr.
Definition at line 824 of file stk_memory_bytepool.h.
References TryNewT().
|
inlineinherited |
Non-blocking TimedNewT(). ISR-safe if the constructor of T is.
Definition at line 806 of file stk_memory_bytepool.h.
References stk::NO_WAIT, and TimedNewT().
Referenced by TryMakeT().
|
staticinherited |
Payload alignment and block size granularity in bytes.
Set with STK_MEMORY_BYTEPOOL_ALIGN_DEFAULT (8 by default).
Definition at line 164 of file stk_memory_bytepool.h.
Referenced by AlignSize(), Free(), HeapSize(), Init(), IsSane(), stk_bytepool_create(), stk_bytepool_create_static(), STK_STATIC_ASSERT_DESC(), stk::memory::detail::STK_STATIC_ASSERT_DESC(), stk::memory::StaticBytePool< TSize >::STK_STATIC_ASSERT_DESC(), stk::memory::StaticBytePool< TSize >::STK_STATIC_ASSERT_DESC(), STK_STATIC_ASSERT_DESC(), and TimedAllocT().
|
staticprivateinherited |
payload fill on allocation (STK_MEMORY_POOL_CHECKS)
Definition at line 470 of file stk_memory_bytepool.h.
Referenced by ScanRange().
|
staticprivateinherited |
payload fill on free (STK_MEMORY_POOL_CHECKS)
Definition at line 471 of file stk_memory_bytepool.h.
Referenced by Free().
|
staticprivateinherited |
value of the guard word of a used block
Definition at line 464 of file stk_memory_bytepool.h.
Referenced by Free(), and ScanRange().
|
staticprivateinherited |
Size of the overrun guard word at the end of every used block (0 = disabled).
Definition at line 462 of file stk_memory_bytepool.h.
Referenced by GetMaxRequest(), RequiredSize(), and ScanRange().
|
staticinherited |
Size of the per-block header in bytes: max(8, BLOCK_ALIGN).
Every allocation consumes HEADER_SIZE bytes of the pool in addition to its (aligned) payload. It is a multiple of BLOCK_ALIGN so the payload that directly follows the header is aligned as well.
Definition at line 174 of file stk_memory_bytepool.h.
Referenced by AccountRun(), Free(), GetMaxRequest(), Init(), RequiredSize(), ScanRange(), stk_bytepool_create(), stk_bytepool_create_static(), stk::memory::StaticBytePool< TSize >::STK_STATIC_ASSERT_DESC(), and STK_STATIC_ASSERT_DESC().
|
inherited |
Definition at line 1168 of file stk_memory_bytepool.h.
Referenced by stk::memory::StaticBytePool< TSize >::StaticBytePool().
|
privateinherited |
signalled by Free() to wake tasks blocked in TimedAlloc()
Definition at line 549 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), Free(), and TimedAllocEx().
|
privateinherited |
one past the last block (aligned), nullptr if the pool is invalid
Definition at line 547 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), Coalesce(), FindFree(), Free(), GetInfo(), GetSize(), Init(), IsBlockStart(), IsSane(), ScanRange(), and ~BytePool().
|
privateinherited |
first block header (aligned), nullptr if the pool is invalid
Definition at line 546 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), FindFree(), Free(), GetInfo(), GetSize(), Init(), IsBlockStart(), IsStorageValid(), ScanRange(), and ~BytePool().
|
privateinherited |
longest block-list walk of a single allocation
Definition at line 552 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), FindFree(), and GetMaxScanLength().
|
privateinherited |
where the next search starts (STK_MEMORY_BYTEPOOL_NEXT_FIT)
Definition at line 548 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), Coalesce(), FindFree(), Init(), and ScanRange().
|
privateinherited |
live statistics: bytes of used blocks (headers included), watermark, counters
Definition at line 551 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), Free(), GetAllocFailCount(), GetPeakUsedSize(), GetStats(), Init(), ScanRange(), TimedAllocEx(), and ~BytePool().
|
privateinherited |
raw storage as supplied or allocated (before alignment)
Definition at line 545 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), Init(), and ~BytePool().
|
privateinherited |
true -> storage is heap-allocated; free in destructor
Definition at line 553 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), and ~BytePool().
|
privateinherited |
size of the raw storage in bytes
Definition at line 550 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), Init(), and ~BytePool().
|
staticprivateinherited |
Smallest block: a header plus the minimum payload (BLOCK_ALIGN).
Also the smallest remainder worth splitting off.
Definition at line 454 of file stk_memory_bytepool.h.
Referenced by BytePool(), BytePool(), GetMaxRequest(), Init(), IsSane(), and ScanRange().
|
staticprivateinherited |
Largest managed area: block sizes are stored as 32-bit values (kept a multiple of BLOCK_ALIGN).
Definition at line 458 of file stk_memory_bytepool.h.
Referenced by Init().
|
staticprivateinherited |
"FREE"
Definition at line 466 of file stk_memory_bytepool.h.
Referenced by Coalesce(), Free(), GetInfo(), Init(), IsSane(), and ScanRange().
|
staticprivateinherited |
stale header absorbed by a merge
Definition at line 468 of file stk_memory_bytepool.h.
Referenced by Coalesce().
|
staticprivateinherited |
"USED"
Definition at line 467 of file stk_memory_bytepool.h.
Referenced by Free(), IsSane(), and ScanRange().