mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 14:42:29 +02:00

This reverts commit 2d33c20231
and
reapplies various patches for memory leaks.
The reason for the revert was a bug for a maximum duration interval
which caused sleep_for() to cause unpredictable behavior.
22 lines
471 B
C++
22 lines
471 B
C++
#pragma once
|
|
|
|
#include <utility>
|
|
|
|
namespace waybar::util {
|
|
|
|
template <typename Func>
|
|
class scope_guard {
|
|
public:
|
|
explicit scope_guard(Func&& exit_function) : f{std::forward<Func>(exit_function)} {}
|
|
scope_guard(const scope_guard&) = delete;
|
|
scope_guard(scope_guard&&) = default;
|
|
scope_guard& operator=(const scope_guard&) = delete;
|
|
scope_guard& operator=(scope_guard&&) = default;
|
|
~scope_guard() { f(); }
|
|
|
|
private:
|
|
Func f;
|
|
};
|
|
|
|
} // namespace waybar::util
|