* @brief This function will detach a static event object. * * @note This function is used to detach a static event object which is initialized by rt_event_init() function. * By contrast, the rt_event_delete() function will delete an event object. * When the event is successfully detached, it will resume all suspended threads in the event list. * * @see rt_even
| 1828 | * ONLY USE the rt_event_delete() function to complete the deletion. |
| 1829 | */ |
| 1830 | rt_err_t rt_event_detach(rt_event_t event) |
| 1831 | { |
| 1832 | rt_base_t level; |
| 1833 | |
| 1834 | /* parameter check */ |
| 1835 | RT_ASSERT(event != RT_NULL); |
| 1836 | RT_ASSERT(rt_object_get_type(&event->parent.parent) == RT_Object_Class_Event); |
| 1837 | RT_ASSERT(rt_object_is_systemobject(&event->parent.parent)); |
| 1838 | |
| 1839 | level = rt_spin_lock_irqsave(&(event->spinlock)); |
| 1840 | /* resume all suspended thread */ |
| 1841 | rt_susp_list_resume_all(&(event->parent.suspend_thread), RT_ERROR); |
| 1842 | rt_spin_unlock_irqrestore(&(event->spinlock), level); |
| 1843 | |
| 1844 | /* detach event object */ |
| 1845 | rt_object_detach(&(event->parent.parent)); |
| 1846 | |
| 1847 | return RT_EOK; |
| 1848 | } |
| 1849 | RTM_EXPORT(rt_event_detach); |
| 1850 | |
| 1851 | #ifdef RT_USING_HEAP |