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);
|
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 util
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
12
src/util.h
12
src/util.h
|
@ -622,17 +622,5 @@ 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));
|
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 util
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue