mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Move Deferred class from ZeroMQ to util
This commit is contained in:
parent
c68dfdca2f
commit
850b20e12b
2 changed files with 13 additions and 11 deletions
12
src/util.h
12
src/util.h
|
@ -662,5 +662,17 @@ inline std::vector<std::wstring_view> split(const wchar_t* s, const wchar_t* del
|
|||
return split(std::wstring_view(s), std::wstring_view(delim));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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