mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 18:57:16 +08:00
[kernel] add rt_thread_close()
* [thread] Add rt_thread_close() This patch introduces a new function `rt_thread_close()` to enhances the usability and maintainability by providing a dedicated mechanism for closing threads. - A new function `rt_thread_close()` is added to the API, providing a standardized approach for closing threads. - The `rt_thread_close()` function removes a thread from the thread queue, updates its status to indicate closure, and performs the thread timer detaching which is a embedded timer in thread object. - Additionally, the `rt_thread_detach()` function is modified to utilize `rt_thread_close()` internally, streamlining the thread detachment process. Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
@@ -202,19 +202,11 @@ void dlmodule_destroy_subthread(struct rt_dlmodule *module, rt_thread_t thread)
|
||||
/* lock scheduler to prevent scheduling in cleanup function. */
|
||||
rt_enter_critical();
|
||||
|
||||
/* remove thread from thread_list (ready or defunct thread list) */
|
||||
rt_thread_close(thread);
|
||||
|
||||
/* remove thread from thread_list (defunct thread list) */
|
||||
rt_list_remove(&RT_THREAD_LIST_NODE(thread));
|
||||
|
||||
if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_CLOSE &&
|
||||
(thread->thread_timer.parent.type == (RT_Object_Class_Static | RT_Object_Class_Timer)))
|
||||
{
|
||||
/* release thread timer */
|
||||
rt_timer_detach(&(thread->thread_timer));
|
||||
}
|
||||
|
||||
/* change stat */
|
||||
thread->stat = RT_THREAD_CLOSE;
|
||||
|
||||
/* invoke thread cleanup */
|
||||
if (thread->cleanup != RT_NULL)
|
||||
thread->cleanup(thread);
|
||||
|
||||
Reference in New Issue
Block a user