Skip to content

Commit 057bd31

Browse files
committed
Merge #19197: init: use std::thread for ThreadImport()
83fd3a6 init: use std::thread for ThreadImport() (fanquake) Pull request description: [Mentioned](bitcoin/bitcoin#19142 (comment)) in #19142, which removed the `boost::interruption_point()` in `ThreadImport()`. ACKs for top commit: hebasto: ACK 83fd3a6, I have reviewed the code and it looks OK, I agree it can be merged. donaloconnor: ACK 83fd3a6 laanwj: Code review ACK 83fd3a6 MarcoFalke: ACK 83fd3a6 Tree-SHA512: 0644947d669feb61eed3a944012dad1bd3dd75cf994aa2630013043c213a335b162b63e20aa37e0997740d8e3a3ec367b660b5196007a09e13f0ac455b36c821
2 parents dbd7a91 + 83fd3a6 commit 057bd31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/init.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ NODISCARD static bool CreatePidFile()
152152

153153
static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
154154

155+
static std::thread g_load_block;
156+
155157
static boost::thread_group threadGroup;
156158

157159
void Interrupt(NodeContext& node)
@@ -214,8 +216,9 @@ void Shutdown(NodeContext& node)
214216
StopTorControl();
215217

216218
// After everything has been shut down, but before things get flushed, stop the
217-
// CScheduler/checkqueue threadGroup
219+
// CScheduler/checkqueue, threadGroup and load block thread.
218220
if (node.scheduler) node.scheduler->stop();
221+
if (g_load_block.joinable()) g_load_block.join();
219222
threadGroup.interrupt_all();
220223
threadGroup.join_all();
221224

@@ -680,7 +683,6 @@ static void CleanupBlockRevFiles()
680683
static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles)
681684
{
682685
const CChainParams& chainparams = Params();
683-
util::ThreadRename("loadblk");
684686
ScheduleBatchPriority();
685687

686688
{
@@ -1842,7 +1844,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node)
18421844
vImportFiles.push_back(strFile);
18431845
}
18441846

1845-
threadGroup.create_thread([=, &chainman] { ThreadImport(chainman, vImportFiles); });
1847+
g_load_block = std::thread(&TraceThread<std::function<void()>>, "loadblk", [=, &chainman]{ ThreadImport(chainman, vImportFiles); });
18461848

18471849
// Wait for genesis block to be processed
18481850
{

0 commit comments

Comments
 (0)