* @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
| 2396 | * ONLY USE the rt_mb_delete() function to complete the deletion. |
| 2397 | */ |
| 2398 | rt_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 | } |
| 2419 | RTM_EXPORT(rt_mb_detach); |
| 2420 | |
| 2421 | #ifdef RT_USING_HEAP |