feat remove defer
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m50s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 2m39s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 3m33s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 2m4s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 3m15s
linux-x64-gcc / linux-gcc (push) Failing after 1m49s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 11m39s
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m50s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 2m39s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 3m33s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 2m4s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 3m15s
linux-x64-gcc / linux-gcc (push) Failing after 1m49s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 11m39s
This commit is contained in:
parent
2e4bd2d083
commit
fc85ca4d2e
@ -18,20 +18,17 @@ public:
|
||||
|
||||
Defer(DeferFunc &&defer_func) { Add(std::move(defer_func)); }
|
||||
|
||||
Defer(Defer &&other) noexcept : defer_funcs_(std::move(other.defer_funcs_))
|
||||
{}
|
||||
Defer(Defer &&other) noexcept : defer_funcs_(std::move(other.defer_funcs_)) {}
|
||||
|
||||
~Defer()
|
||||
{
|
||||
std::for_each(defer_funcs_.rbegin(), defer_funcs_.rend(),
|
||||
[](const DeferFunc &defer_func) { defer_func(); });
|
||||
std::for_each(defer_funcs_.rbegin(), defer_funcs_.rend(), [](const DeferFunc &defer_func) { defer_func(); });
|
||||
}
|
||||
|
||||
template<typename F, typename... Args>
|
||||
void Add(F &&func, Args &&...args)
|
||||
{
|
||||
defer_funcs_.push_back(
|
||||
std::bind(std::forward<F>(func), std::forward<Args>(args)...));
|
||||
defer_funcs_.push_back(std::bind(std::forward<F>(func), std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void Clear() { defer_funcs_.clear(); }
|
||||
@ -40,12 +37,12 @@ private:
|
||||
std::vector<DeferFunc> defer_funcs_;
|
||||
};
|
||||
|
||||
#define _ULIB_DEFER_CONCAT(a, b) a##b
|
||||
#define ULIB_DEFER_CONCAT(a, b) _ULIB_DEFER_CONCAT(a, b)
|
||||
// #define _ULIB_DEFER_CONCAT(a, b) a##b
|
||||
// #define ULIB_DEFER_CONCAT(a, b) _ULIB_DEFER_CONCAT(a, b)
|
||||
|
||||
#define defer(x) \
|
||||
::ulib::Defer ULIB_DEFER_CONCAT(__ulib_defer__, __LINE__) = \
|
||||
::ulib::Defer(x);
|
||||
// #define defer(x) \
|
||||
// ::ulib::Defer ULIB_DEFER_CONCAT(__ulib_defer__, __LINE__) = \
|
||||
// ::ulib::Defer(x);
|
||||
|
||||
}// namespace ulib
|
||||
#endif// ULIB_SRC_ULIB_UTILS_DEFER_H_
|
||||
|
Loading…
Reference in New Issue
Block a user