mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 11:07:34 +00:00
Added Mempool
This commit is contained in:
40
include/sta/rtos/mempool.tpp
Normal file
40
include/sta/rtos/mempool.tpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef STA_RTOS_MEMPOOL_TPP
|
||||
#define STA_RTOS_MEMPOOL_TPP
|
||||
|
||||
#ifndef STA_RTOS_MEMPOOL_HPP
|
||||
# error "Internal header. Use <sta/rtos/mempool.hpp> instead."
|
||||
#endif // !STA_RTOS_MEMPOOL_HPP
|
||||
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
template <typename T>
|
||||
RtosMemPool<T>::RtosMemPool()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
RtosMemPool<T>::RtosMemPool(uint32_t block_count, uint32_t block_size)
|
||||
{
|
||||
osMemoryPoolAttr_t mp_attr = { .name = "MemoryPool" };
|
||||
handle_ = osMemoryPoolNew(block_size, block_count, &mp_attr);
|
||||
STA_ASSERT_MSG(handle_ != nullptr, "Failed to Create RtosMemPool");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void * RtosMemPool<T>::alloc(uint32_t timeout /* = osWaitForever */)
|
||||
{
|
||||
return osMemoryPoolAlloc(handle_, timeout);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
osStatus_t RtosMemPool<T>::free(void * block)
|
||||
{
|
||||
return osMemoryPoolFree(handle_, block);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
|
||||
#endif // STA_RTOS_MEMPOOL_TPP
|
Reference in New Issue
Block a user