* This function will wakeup a thread with customized operation. * * @param thread the thread to be resumed * * @return the operation status, RT_EOK on OK, -RT_ERROR on error */
| 1134 | * @return the operation status, RT_EOK on OK, -RT_ERROR on error |
| 1135 | */ |
| 1136 | rt_err_t rt_thread_wakeup(rt_thread_t thread) |
| 1137 | { |
| 1138 | rt_sched_lock_level_t slvl; |
| 1139 | rt_err_t ret; |
| 1140 | rt_wakeup_func_t func = RT_NULL; |
| 1141 | |
| 1142 | RT_ASSERT(thread != RT_NULL); |
| 1143 | RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); |
| 1144 | |
| 1145 | rt_sched_lock(&slvl); |
| 1146 | func = thread->wakeup_handle.func; |
| 1147 | thread->wakeup_handle.func = RT_NULL; |
| 1148 | rt_sched_unlock(slvl); |
| 1149 | |
| 1150 | if (func) |
| 1151 | { |
| 1152 | ret = func(thread->wakeup_handle.user_data, thread); |
| 1153 | } |
| 1154 | else |
| 1155 | { |
| 1156 | ret = rt_thread_resume(thread); |
| 1157 | } |
| 1158 | return ret; |
| 1159 | } |
| 1160 | RTM_EXPORT(rt_thread_wakeup); |
| 1161 | |
| 1162 | void rt_thread_wakeup_set(struct rt_thread *thread, rt_wakeup_func_t func, void* user_data) |
no test coverage detected