File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ osStatus Thread::start(Callback<void()> task) {
103
103
}
104
104
105
105
osStatus Thread::terminate () {
106
- osStatus_t ret;
106
+ osStatus_t ret = osOK ;
107
107
_mutex.lock ();
108
108
109
109
// Set the Thread's tid to NULL and
@@ -112,11 +112,11 @@ osStatus Thread::terminate() {
112
112
osThreadId_t local_id = _tid;
113
113
_join_sem.release ();
114
114
_tid = (osThreadId_t)NULL ;
115
- _finished = true ;
115
+ if (!_finished) {
116
+ _finished = true ;
117
+ ret = osThreadTerminate (local_id);
118
+ }
116
119
_mutex.unlock ();
117
-
118
- ret = osThreadTerminate (local_id);
119
-
120
120
return ret;
121
121
}
122
122
@@ -352,8 +352,8 @@ void Thread::_thunk(void * thread_ptr)
352
352
t->_mutex .lock ();
353
353
t->_tid = (osThreadId)NULL ;
354
354
t->_finished = true ;
355
- t->_mutex .unlock ();
356
355
t->_join_sem .release ();
356
+ // rtos will release the mutex automatically
357
357
}
358
358
359
359
}
You can’t perform that action at this time.
0 commit comments