diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-02-21 15:43:43 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-02-21 15:43:43 +0100 |
commit | ddb6740e7da2ec0cc6ad71ac7e40f8513a1103c2 (patch) | |
tree | 38ebe59aa8b8852c17652fcc677d44b38b1e5480 /src/libutil | |
parent | c3b942e0fc4777f9033f614b6b1f462c0f8c473e (diff) |
triggerInterrupt: Refactor to use break
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.cc | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 03cbd7765..44463161f 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1599,28 +1599,24 @@ void triggerInterrupt() { InterruptCallbacks::Token i = 0; - std::function<void()> callback; - do { + while (true) { + std::function<void()> callback; { auto interruptCallbacks(_interruptCallbacks.lock()); auto lb = interruptCallbacks->callbacks.lower_bound(i); - if (lb != interruptCallbacks->callbacks.end()) { - callback = lb->second; - i = lb->first + 1; - } else { - callback = nullptr; - } + if (lb == interruptCallbacks->callbacks.end()) + break; + + callback = lb->second; + i = lb->first + 1; } - if (callback) { - try { - callback(); - } catch (...) { - ignoreException(); - } + try { + callback(); + } catch (...) { + ignoreException(); } } - while (callback); } } |