Skip to content

Commit 1b2a68a

Browse files
authored
Merge pull request #12941 from kjbracey-arm/chrono-timeout-fix
Correct Timeout rescheduling
2 parents 7698b34 + 0a9e1db commit 1b2a68a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/source/Timeout.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ namespace mbed {
2727
void TimeoutBase::handler()
2828
{
2929
if (_function) {
30+
Callback<void()> function_to_call = _function;
31+
// Clean up state to "detached" before calling callback; it may attach
32+
// a new callback. Equivalent to detach(), but skips the remove();
33+
// it's unnecessary because we're in the ticker's handler.
34+
_function = nullptr;
3035
if (_lock_deepsleep) {
3136
sleep_manager_unlock_deep_sleep();
3237
}
33-
_function();
34-
_function = nullptr;
38+
function_to_call();
3539
}
3640
}
3741

0 commit comments

Comments
 (0)