fix compile error #4

Merged
tqcq merged 13 commits from feat/support_fiber into master 2024-07-08 17:53:24 +08:00
2 changed files with 40 additions and 4 deletions
Showing only changes of commit 2b69c377f7 - Show all commits

View File

@ -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

View File

@ -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;