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

Function rt_mb_detach

src/ipc.c:2398–2418  ·  view source on GitHub ↗

* @brief This function will detach a static mailbox object. * * @note This function is used to detach a static mailbox object which is initialized by rt_mb_init() function. * By contrast, the rt_mb_delete() function will delete a mailbox object. * When the mailbox is successfully detached, it will resume all suspended threads in the mailbox list. * * @see rt_m

Source from the content-addressed store, hash-verified

2396 * ONLY USE the rt_mb_delete() function to complete the deletion.
2397 */
2398rt_err_t rt_mb_detach(rt_mailbox_t mb)
2399{
2400 rt_base_t level;
2401
2402 /* parameter check */
2403 RT_ASSERT(mb != RT_NULL);
2404 RT_ASSERT(rt_object_get_type(&mb->parent.parent) == RT_Object_Class_MailBox);
2405 RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent));
2406
2407 level = rt_spin_lock_irqsave(&(mb->spinlock));
2408 /* resume all suspended thread */
2409 rt_susp_list_resume_all(&(mb->parent.suspend_thread), RT_ERROR);
2410 /* also resume all mailbox private suspended thread */
2411 rt_susp_list_resume_all(&(mb->suspend_sender_thread), RT_ERROR);
2412 rt_spin_unlock_irqrestore(&(mb->spinlock), level);
2413
2414 /* detach mailbox object */
2415 rt_object_detach(&(mb->parent.parent));
2416
2417 return RT_EOK;
2418}
2419RTM_EXPORT(rt_mb_detach);
2420
2421#ifdef RT_USING_HEAP

Callers 5

dlmodule_destroyFunction · 0.85
~MailMethod · 0.85
test_mailbox_initFunction · 0.85
test_mailbox_deatchFunction · 0.85

Calls 6

rt_object_get_typeFunction · 0.85
rt_susp_list_resume_allFunction · 0.85
rt_object_detachFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.70

Tested by 3

test_mailbox_initFunction · 0.68
test_mailbox_deatchFunction · 0.68