#ifndef _aplmt_memory_mempoolapi_h_ #define _aplmt_memory_mempoolapi_h_ /*---------------------------------------------------------------------------- ** SUMMARY: Memory Pool Interface (MEMPOOLMT) ** ** DESCRIPTION: ** This file provides thread-safe extensions to the basic APL MEMPOOL ** interface. The application must 'build' the basic MEMPOOL interface and ** follow all of the setup/configuration specified for that interface. This ** MT interface can be used in 'parallel' (i.e. co-exist) with other Memory ** interfaces (threaded or non-threaded). In fact, it is technically OK ** to mix the calls to the the basic MEMPOOL interfaces with calls to this ** interface (MEMPOOLMT), JUST BE SURE YOU KNOW WHAT YOU ARE DOING. ** ** OUT-OF-MEMORY ** ------------- ** See apl/memory/mempoolapi.h ** ** MEMORY ALIGNMENT ** ---------------- ** See apl/memory/mempoolapi.h ** ** ** CONFIGURATION ** ------------- ** COMPILE: See apl/memory/mempoolapi.h ** ** APPLICATION: See apl/memory/mempoolapi.h ** ** PLATFORM: none. ** ** ** NOTES: ** 1. Unless explicitly stated otherwise, NONE of the following methods may be ** called from interrupt service routines. ** 2. Unless explicitly stated otherwise, NONE of the following methods may be ** called before the platform's kernel is running. ** 3. Unless explicitly stated otherwise, all of the following methods ARE ** thread-safe. ** 4. For efficency/optimization some methods are 'inlined'. The inlining ** is done by using the preprocessor/macros. The application should ** treat all methods as function calls and not rely on the fact they may ** be currently defined as macros. ----------------------------------------------------------------------------*/ #include "apl/memory/mempoolapi.h" /* For: parent/base interface */ #ifdef __cplusplus extern "C" { #endif /*-------------- INLINE IMPLEMENTATION -------------------------------------*/ #include "aplmt/memory/mempool.h" /* For: inline MTimplementation */ /*-------------- INHERITED PARENT API --------------------------------------*/ /** The parent/base API methods are enumerated below. The inherited methods are NOT thread-safe. For a up-to-date list reference the parent class directly. Prototypes: AplMemPoolHdl Apl_memPoolCreate( void* rawMemory, AplSize_t rawMemorySize, AplSize_t userBlockSize ); void* Apl_memPoolAllocate( AplMemPoolHdl poolToAllocateFrom ); void Apl_memPoolFree( AplMemPoolHdl poolMemoryWasAllocatedFrom, void* blockToFree ); */ /*-------------- PUBLIC/PUBLISHED API --------------------------------------*/ /** This method is a thread-safe version of Apl_memPoolAllocate() NOTES: o This method can ONLY be called once the kernel is running. o This method is thread-safe, and as such may: block on a mutex, disable scheduling, or disable interrupts for the duration of the call (it is platform dependent). o This method can be called from both a thread context as well as an ISR context. o As a general rule, do NOT mix calls to the non-thread safe and thread safe version of pool alloc. If you do mix the different types of calls, MAKE SURE YOU KNOW WHAT YOUR ARE DOING. Prototype: void* Aplmt_memPoolAllocate( AplMemPoolHdl poolToAllocateFrom ); */ #define Aplmt_memPoolAllocate _Aplmt_memPoolAllocate /** This method is a thread-safe version of Apl_memPoolFree(). NOTES: o This method can ONLY be called once the kernel is running. o This method is thread-safe, and as such may: block on a mutex, disable scheduling, or disable interrupts for the duration of the call (it is platform dependent). o This method can be called from both a thread context as well as an ISR context. o It is OK to free memory allocated by Apl_memPoolAllocate() with this method. Prototype: void Aplmt_memPoolFree( AplMemPoolHdl poolMemoryWasAllocatedFrom, void* blockToFree ); */ #define Aplmt_memPoolFree _Aplmt_memPoolFree #ifdef __cplusplus } #endif /*--------------------------------------------------------------------------*/ #endif /* end _aplmt_memory_mempoolapi_h_ */