diff options
author | fanquake <fanquake@gmail.com> | 2020-06-19 12:54:58 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-06-19 13:29:03 +0800 |
commit | 057bd3189f12be40e641023ea3a0d9ffe5079ddb (patch) | |
tree | dd03a4e479d226f603fbf9dce1b05d74eea3872f /src | |
parent | dbd7a91fdf3ff801fe5e4107e8346d0d6d11a899 (diff) | |
parent | 83fd3a6d73eee452dc5141bdf6826da62d7b2dbd (diff) | |
download | bitcoin-057bd3189f12be40e641023ea3a0d9ffe5079ddb.tar.xz |
Merge #19197: init: use std::thread for ThreadImport()
83fd3a6d73eee452dc5141bdf6826da62d7b2dbd init: use std::thread for ThreadImport() (fanquake)
Pull request description:
[Mentioned](https://github.com/bitcoin/bitcoin/pull/19142#issuecomment-638090759) in #19142, which removed the `boost::interruption_point()`
in `ThreadImport()`.
ACKs for top commit:
hebasto:
ACK 83fd3a6d73eee452dc5141bdf6826da62d7b2dbd, I have reviewed the code and it looks OK, I agree it can be merged.
donaloconnor:
ACK 83fd3a6
laanwj:
Code review ACK 83fd3a6d73eee452dc5141bdf6826da62d7b2dbd
MarcoFalke:
ACK 83fd3a6d73eee452dc5141bdf6826da62d7b2dbd
Tree-SHA512: 0644947d669feb61eed3a944012dad1bd3dd75cf994aa2630013043c213a335b162b63e20aa37e0997740d8e3a3ec367b660b5196007a09e13f0ac455b36c821
Diffstat (limited to 'src')
-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 { |