Skip to content

Commit

Permalink
Merge #19197: init: use std::thread for ThreadImport()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fanquake committed Jun 19, 2020
2 parents dbd7a91 + 83fd3a6 commit 057bd31
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 057bd31

Please sign in to comment.