* @brief This function will delete a mutex object and release this memory space. * * @note This function is used to delete a mutex object which is created by the rt_mutex_create() function. * By contrast, the rt_mutex_detach() function will detach a static mutex object. * When the mutex is successfully deleted, it will resume all suspended threads in the mutex list.
| 1282 | * ONLY USE the rt_mutex_detach() function to complete the detachment. |
| 1283 | */ |
| 1284 | rt_err_t rt_mutex_delete(rt_mutex_t mutex) |
| 1285 | { |
| 1286 | /* parameter check */ |
| 1287 | RT_ASSERT(mutex != RT_NULL); |
| 1288 | RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex); |
| 1289 | RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE); |
| 1290 | |
| 1291 | RT_DEBUG_NOT_IN_INTERRUPT; |
| 1292 | |
| 1293 | _mutex_before_delete_detach(mutex); |
| 1294 | |
| 1295 | /* delete mutex object */ |
| 1296 | rt_object_delete(&(mutex->parent.parent)); |
| 1297 | |
| 1298 | return RT_EOK; |
| 1299 | } |
| 1300 | RTM_EXPORT(rt_mutex_delete); |
| 1301 | #endif /* RT_USING_HEAP */ |
| 1302 |