feat make_unique support deleter
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 1m30s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 1m50s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 1m50s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 1m48s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 2m0s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Failing after 2m2s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 1m32s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Failing after 1m53s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 1m37s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 1m53s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 3m12s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Failing after 1m45s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m2s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 1m26s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 1m42s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 1m35s
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 1m30s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 1m50s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 1m50s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 1m48s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 2m0s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Failing after 2m2s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 1m32s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Failing after 1m53s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 1m37s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 1m53s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 3m12s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Failing after 1m45s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m2s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 1m26s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 1m42s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 1m35s
This commit is contained in:
parent
fc369b3707
commit
2b69c377f7
@ -21,7 +21,7 @@ make_unique(Args &&...args) {
|
||||
template <typename T>
|
||||
inline enable_if_t<std::is_array<T>::value && std::extent<T>::value == 0,
|
||||
std::unique_ptr<T>>
|
||||
make_unique(size_t size) {
|
||||
make_unique(std::size_t size) {
|
||||
TILE_DCHECK(size > 0);
|
||||
using U = typename std::remove_extent<T>::type;
|
||||
return std::unique_ptr<T>(new U[size]());
|
||||
@ -34,6 +34,29 @@ enable_if_t<std::is_array<T>::value && std::extent<T>::value != 0,
|
||||
std::unique_ptr<T>>
|
||||
make_unique(Args &&...) = delete;
|
||||
|
||||
// == With Deleter
|
||||
|
||||
template <typename T, typename D, typename... Args>
|
||||
inline enable_if_t<!std::is_array<T>::value, std::unique_ptr<T, D>>
|
||||
make_unique_with_deleter(D &&deleter, Args &&...args) {
|
||||
return std::unique_ptr<T, D>(new T(std::forward<Args>(args)...),
|
||||
std::forward<D>(deleter));
|
||||
}
|
||||
|
||||
template <typename T, typename D>
|
||||
inline enable_if_t<std::is_array<T>::value && std::extent<T>::value == 0,
|
||||
std::unique_ptr<T, D>>
|
||||
make_unique_with_deleter(D &&deleter, std::size_t size) {
|
||||
TILE_DCHECK(size > 0);
|
||||
using U = typename std::remove_extent<T>::type;
|
||||
return std::unique_ptr<T, D>(new U[size](), std::forward<D>(deleter));
|
||||
}
|
||||
|
||||
template <typename T, typename D, typename... Args>
|
||||
enable_if_t<std::is_array<T>::value && std::extent<T>::value != 0,
|
||||
std::unique_ptr<T, D>>
|
||||
make_unique_with_deleter(D &&deleter, Args &&...) = delete;
|
||||
|
||||
} // namespace tile
|
||||
|
||||
#endif // TILE_BASE_MAKE_UNIQUE_H
|
||||
|
19
tile/init.cc
19
tile/init.cc
@ -53,18 +53,31 @@ int Start(int argc, char **argv, std::function<int(int, char **)> cb,
|
||||
google::InstallFailureSignalHandler();
|
||||
}
|
||||
|
||||
// Init gflags
|
||||
gflags::SetVersionString("0.1.0");
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
detail::ApplyFlagOverrider();
|
||||
auto gflags_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||
[](void *) { gflags::ShutDownCommandLineFlags(); });
|
||||
|
||||
// Init Glog
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
auto glog_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||
[](void *) { google::ShutdownGoogleLogging(); });
|
||||
|
||||
TILE_LOG_INFO("Tile started.");
|
||||
|
||||
TILE_PCHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR);
|
||||
|
||||
// Init BasicRuntime
|
||||
InitializeBasicRuntime();
|
||||
auto basic_runtime_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||
[](void *) { TerminateBasicRuntime(); });
|
||||
|
||||
// Run all initializers
|
||||
detail::RunAllInitializers();
|
||||
auto initializers_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||
[](void *) { detail::RunAllInitializers(); });
|
||||
|
||||
int rc = 0;
|
||||
|
||||
@ -87,9 +100,9 @@ int Start(int argc, char **argv, std::function<int(int, char **)> cb,
|
||||
worker.join();
|
||||
}
|
||||
|
||||
detail::RunAllFinalizers();
|
||||
TerminateBasicRuntime();
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
// detail::RunAllFinalizers();
|
||||
// TerminateBasicRuntime();
|
||||
// gflags::ShutDownCommandLineFlags();
|
||||
TILE_LOG_INFO("Exited");
|
||||
|
||||
return rc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user