mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Move util::Deferred into util-types.h
This commit is contained in:
parent
e91e9c4523
commit
6e96cb59ec
2 changed files with 12 additions and 12 deletions
|
@ -62,5 +62,17 @@ private:
|
|||
void DoFunc(const std::string& path, bool error_aborts = true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper class that runs a function at destruction.
|
||||
*/
|
||||
class Deferred {
|
||||
public:
|
||||
Deferred(std::function<void()> deferred) : deferred(std::move(deferred)) {}
|
||||
~Deferred() { deferred(); }
|
||||
|
||||
private:
|
||||
std::function<void()> deferred;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue