| 494 | RTM_EXPORT(rt_thread_detach); |
| 495 | |
| 496 | static rt_err_t _thread_detach(rt_thread_t thread) |
| 497 | { |
| 498 | rt_err_t error; |
| 499 | rt_base_t critical_level; |
| 500 | |
| 501 | /** |
| 502 | * forbid scheduling on current core before returning since current thread |
| 503 | * may be detached from scheduler. |
| 504 | */ |
| 505 | critical_level = rt_enter_critical(); |
| 506 | |
| 507 | error = rt_thread_close(thread); |
| 508 | |
| 509 | _thread_detach_from_mutex(thread); |
| 510 | |
| 511 | /* insert to defunct thread list */ |
| 512 | rt_thread_defunct_enqueue(thread); |
| 513 | |
| 514 | rt_exit_critical_safe(critical_level); |
| 515 | return error; |
| 516 | } |
| 517 | |
| 518 | #ifdef RT_USING_HEAP |
| 519 | /** |
no test coverage detected