MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_mb_delete

Function rt_mb_delete

src/ipc.c:2513–2538  ·  view source on GitHub ↗

* @brief This function will delete a mailbox object and release the memory space. * * @note This function is used to delete a mailbox object which is created by the rt_mb_create() function. * By contrast, the rt_mb_detach() function will detach a static mailbox object. * When the mailbox is successfully deleted, it will resume all suspended threads in the mailbox lis

Source from the content-addressed store, hash-verified

2511 * ONLY USE the rt_mb_detach() function to complete the detachment.
2512 */
2513rt_err_t rt_mb_delete(rt_mailbox_t mb)
2514{
2515 /* parameter check */
2516 RT_ASSERT(mb != RT_NULL);
2517 RT_ASSERT(rt_object_get_type(&mb->parent.parent) == RT_Object_Class_MailBox);
2518 RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE);
2519
2520 RT_DEBUG_NOT_IN_INTERRUPT;
2521 rt_spin_lock(&(mb->spinlock));
2522
2523 /* resume all suspended thread */
2524 rt_susp_list_resume_all(&(mb->parent.suspend_thread), RT_ERROR);
2525
2526 /* also resume all mailbox private suspended thread */
2527 rt_susp_list_resume_all(&(mb->suspend_sender_thread), RT_ERROR);
2528
2529 rt_spin_unlock(&(mb->spinlock));
2530
2531 /* free mailbox pool */
2532 RT_KERNEL_FREE(mb->msg_pool);
2533
2534 /* delete mailbox object */
2535 rt_object_delete(&(mb->parent.parent));
2536
2537 return RT_EOK;
2538}
2539RTM_EXPORT(rt_mb_delete);
2540#endif /* RT_USING_HEAP */
2541

Callers 9

_object_node_deleteFunction · 0.85
sys_mb_createFunction · 0.85
dlmodule_destroyFunction · 0.85
sys_mbox_freeFunction · 0.85
hal_mailbox_deleteFunction · 0.85
test_mailbox_createFunction · 0.85
test_mailbox_deleteFunction · 0.85
perf_thread_mbox1Function · 0.85

Calls 6

rt_object_get_typeFunction · 0.85
rt_susp_list_resume_allFunction · 0.85
rt_object_deleteFunction · 0.85
rt_spin_lockFunction · 0.70
rt_spin_unlockFunction · 0.70

Tested by 3

test_mailbox_createFunction · 0.68
test_mailbox_deleteFunction · 0.68