fix compile error #4
@ -21,7 +21,7 @@ make_unique(Args &&...args) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline enable_if_t<std::is_array<T>::value && std::extent<T>::value == 0,
|
inline enable_if_t<std::is_array<T>::value && std::extent<T>::value == 0,
|
||||||
std::unique_ptr<T>>
|
std::unique_ptr<T>>
|
||||||
make_unique(size_t size) {
|
make_unique(std::size_t size) {
|
||||||
TILE_DCHECK(size > 0);
|
TILE_DCHECK(size > 0);
|
||||||
using U = typename std::remove_extent<T>::type;
|
using U = typename std::remove_extent<T>::type;
|
||||||
return std::unique_ptr<T>(new U[size]());
|
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>>
|
std::unique_ptr<T>>
|
||||||
make_unique(Args &&...) = delete;
|
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
|
} // namespace tile
|
||||||
|
|
||||||
#endif // TILE_BASE_MAKE_UNIQUE_H
|
#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();
|
google::InstallFailureSignalHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init gflags
|
||||||
gflags::SetVersionString("0.1.0");
|
gflags::SetVersionString("0.1.0");
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
detail::ApplyFlagOverrider();
|
detail::ApplyFlagOverrider();
|
||||||
|
auto gflags_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||||
|
[](void *) { gflags::ShutDownCommandLineFlags(); });
|
||||||
|
|
||||||
|
// Init Glog
|
||||||
google::InitGoogleLogging(argv[0]);
|
google::InitGoogleLogging(argv[0]);
|
||||||
|
auto glog_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||||
|
[](void *) { google::ShutdownGoogleLogging(); });
|
||||||
|
|
||||||
TILE_LOG_INFO("Tile started.");
|
TILE_LOG_INFO("Tile started.");
|
||||||
|
|
||||||
TILE_PCHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR);
|
TILE_PCHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR);
|
||||||
|
|
||||||
|
// Init BasicRuntime
|
||||||
InitializeBasicRuntime();
|
InitializeBasicRuntime();
|
||||||
|
auto basic_runtime_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||||
|
[](void *) { TerminateBasicRuntime(); });
|
||||||
|
|
||||||
|
// Run all initializers
|
||||||
detail::RunAllInitializers();
|
detail::RunAllInitializers();
|
||||||
|
auto initializers_handler = tile::make_unique_with_deleter<uint32_t>(
|
||||||
|
[](void *) { detail::RunAllInitializers(); });
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
@ -87,9 +100,9 @@ int Start(int argc, char **argv, std::function<int(int, char **)> cb,
|
|||||||
worker.join();
|
worker.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::RunAllFinalizers();
|
// detail::RunAllFinalizers();
|
||||||
TerminateBasicRuntime();
|
// TerminateBasicRuntime();
|
||||||
gflags::ShutDownCommandLineFlags();
|
// gflags::ShutDownCommandLineFlags();
|
||||||
TILE_LOG_INFO("Exited");
|
TILE_LOG_INFO("Exited");
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user