diff options
author | fanquake <fanquake@gmail.com> | 2020-06-06 20:23:05 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-06-12 16:02:18 +0800 |
commit | 83fd3a6d73eee452dc5141bdf6826da62d7b2dbd (patch) | |
tree | 2d5598872f3ae589234329a9a75d5f0815ddc974 /src/init.cpp | |
parent | b33136b6ba9887f7db651c4c5264ca7f2f601df7 (diff) |
init: use std::thread for ThreadImport()
Mentioned in #19142, which removed the boost::interruption_point()
in ThreadImport().
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp index fd7c8d0f80..8d9566edc3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -152,6 +152,8 @@ NODISCARD static bool CreatePidFile() static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle; +static std::thread g_load_block; + static boost::thread_group threadGroup; void Interrupt(NodeContext& node) @@ -214,8 +216,9 @@ void Shutdown(NodeContext& node) StopTorControl(); // After everything has been shut down, but before things get flushed, stop the - // CScheduler/checkqueue threadGroup + // CScheduler/checkqueue, threadGroup and load block thread. if (node.scheduler) node.scheduler->stop(); + if (g_load_block.joinable()) g_load_block.join(); threadGroup.interrupt_all(); threadGroup.join_all(); @@ -680,7 +683,6 @@ static void CleanupBlockRevFiles() static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles) { const CChainParams& chainparams = Params(); - util::ThreadRename("loadblk"); ScheduleBatchPriority(); { @@ -1842,7 +1844,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node) vImportFiles.push_back(strFile); } - threadGroup.create_thread([=, &chainman] { ThreadImport(chainman, vImportFiles); }); + g_load_block = std::thread(&TraceThread<std::function<void()>>, "loadblk", [=, &chainman]{ ThreadImport(chainman, vImportFiles); }); // Wait for genesis block to be processed { |