* @brief This function will delete an event object and release the memory space. * * @note This function is used to delete an event object which is created by the rt_event_create() function. * By contrast, the rt_event_detach() function will detach a static event object. * When the event is successfully deleted, it will resume all suspended threads in the event list.
| 1924 | * ONLY USE the rt_event_detach() function to complete the detachment. |
| 1925 | */ |
| 1926 | rt_err_t rt_event_delete(rt_event_t event) |
| 1927 | { |
| 1928 | /* parameter check */ |
| 1929 | RT_ASSERT(event != RT_NULL); |
| 1930 | RT_ASSERT(rt_object_get_type(&event->parent.parent) == RT_Object_Class_Event); |
| 1931 | RT_ASSERT(rt_object_is_systemobject(&event->parent.parent) == RT_FALSE); |
| 1932 | |
| 1933 | RT_DEBUG_NOT_IN_INTERRUPT; |
| 1934 | |
| 1935 | rt_spin_lock(&(event->spinlock)); |
| 1936 | /* resume all suspended thread */ |
| 1937 | rt_susp_list_resume_all(&(event->parent.suspend_thread), RT_ERROR); |
| 1938 | rt_spin_unlock(&(event->spinlock)); |
| 1939 | |
| 1940 | /* delete event object */ |
| 1941 | rt_object_delete(&(event->parent.parent)); |
| 1942 | |
| 1943 | return RT_EOK; |
| 1944 | } |
| 1945 | RTM_EXPORT(rt_event_delete); |
| 1946 | #endif /* RT_USING_HEAP */ |
| 1947 |