summaryrefslogtreecommitdiffstats
path: root/BrowserSource/Proxy/ScopeGuard.h
diff options
context:
space:
mode:
Diffstat (limited to 'BrowserSource/Proxy/ScopeGuard.h')
-rw-r--r--BrowserSource/Proxy/ScopeGuard.h32
1 files changed, 0 insertions, 32 deletions
diff --git a/BrowserSource/Proxy/ScopeGuard.h b/BrowserSource/Proxy/ScopeGuard.h
deleted file mode 100644
index 61bb64d..0000000
--- a/BrowserSource/Proxy/ScopeGuard.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include <functional>
-#include <utility>
-
-class ScopeGuard {
-public:
- ScopeGuard(std::function<void()>&& cb) : cb_(std::move(cb)), active_(true) {}
- ~ScopeGuard() {
- Invoke();
- }
-
- ScopeGuard() = delete;
- ScopeGuard(ScopeGuard&) = delete;
- ScopeGuard(const ScopeGuard&) = delete;
- ScopeGuard(ScopeGuard&&) = delete;
- ScopeGuard& operator=(ScopeGuard&) = delete;
- ScopeGuard& operator=(const ScopeGuard&) = delete;
-
- void Cancel() { active_ = false; }
-
- void Invoke() {
- if (active_) {
- cb_();
- active_ = false;
- }
- }
-
-private:
- const std::function<void()> cb_;
- bool active_;
-};