[message] add platform deinit hook and MessagePool dtor (#12202)

Add a MessagePool destructor that calls the new
`otPlatMessagePoolDeinit` hook so platform-managed buffer pools get
torn down.
This commit is contained in:
xusiyu
2025-12-12 09:26:43 -08:00
committed by GitHub
parent cfe47541ea
commit 47f041790d
4 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ extern "C" {
*
* @note This number versions both OpenThread platform and user APIs.
*/
#define OPENTHREAD_API_VERSION (559)
#define OPENTHREAD_API_VERSION (560)
/**
* @addtogroup api-instance
@@ -106,6 +106,15 @@ void otPlatMessagePoolFree(otInstance *aInstance, otMessageBuffer *aBuffer);
*/
uint16_t otPlatMessagePoolNumFreeBuffers(otInstance *aInstance);
/**
* Deinitialize the platform implemented message pool.
*
* Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled.
*
* @param[in] aInstance A pointer to the OpenThread instance.
*/
void otPlatMessagePoolDeinit(otInstance *aInstance);
#ifdef __cplusplus
} // extern "C"
#endif
+4
View File
@@ -58,6 +58,10 @@ MessagePool::MessagePool(Instance &aInstance)
#endif
}
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
MessagePool::~MessagePool(void) { otPlatMessagePoolDeinit(&GetInstance()); }
#endif
Message *MessagePool::Allocate(Message::Type aType, uint16_t aReserveHeader, const Message::Settings &aSettings)
{
Error error = kErrorNone;
+7
View File
@@ -1849,6 +1849,13 @@ public:
*/
explicit MessagePool(Instance &aInstance);
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
/**
* Tears down the object and releases platform managed resources.
*/
~MessagePool(void);
#endif
/**
* Allocates a new message with specified settings.
*