projects
/
libdcp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
87ecaef
)
Add cancel() to ScopeGuard.
v1.8.94
author
Carl Hetherington
<cth@carlh.net>
Sat, 13 Jan 2024 12:34:46 +0000
(13:34 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Sat, 13 Jan 2024 12:34:46 +0000
(13:34 +0100)
src/scope_guard.h
patch
|
blob
|
history
diff --git
a/src/scope_guard.h
b/src/scope_guard.h
index 37b963adaf5db166e63ffd0d515a491ec64ea2cf..d422528c801d150e3198bb9b21e889f91ce399e6 100644
(file)
--- a/
src/scope_guard.h
+++ b/
src/scope_guard.h
@@
-61,11
+61,19
@@
public:
~ScopeGuard()
{
- _function();
+ if (!_cancelled) {
+ _function();
+ }
+ }
+
+ void cancel()
+ {
+ _cancelled = true;
}
private:
std::function<void()> _function;
+ bool _cancelled = false;
};