mirror of https://github.com/ARMmbed/mbed-os.git
Correct Timeout rescheduling
Chrono changes "optimised" `Timeout::handler` in a way that broke users who rescheduled the timeout during their attached callback. Attempted optimisation is less necessary now that `platform.callback-nontrivial` is set to false by default - that setting reduces overhead of copying the `Callback` to almost nothing.pull/12941/head
parent
029109a2f0
commit
0a9e1db181
|
|
@ -27,11 +27,15 @@ namespace mbed {
|
|||
void TimeoutBase::handler()
|
||||
{
|
||||
if (_function) {
|
||||
Callback<void()> function_to_call = _function;
|
||||
// Clean up state to "detached" before calling callback; it may attach
|
||||
// a new callback. Equivalent to detach(), but skips the remove();
|
||||
// it's unnecessary because we're in the ticker's handler.
|
||||
_function = nullptr;
|
||||
if (_lock_deepsleep) {
|
||||
sleep_manager_unlock_deep_sleep();
|
||||
}
|
||||
_function();
|
||||
_function = nullptr;
|
||||
function_to_call();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue