Remove more boost threads #12381

pull theuni wants to merge 4 commits into bitcoin:master from theuni:boost-threads-again changing 8 files +74 −58
  1. theuni commented at 1:17 am on February 8, 2018: member

    This doesn’t completely get rid of boost::thread, but this batch should be easy to review, and leaves us with only threadGroup (scheduler + scriptcheck) remaining.

    Note to reviewers: The upnp diff changes a bunch of whitespace, it’s much more clear with ‘git diff -w’

  2. fanquake added the label Refactoring on Feb 8, 2018
  3. fanquake added this to the "In progress" column in a project

  4. dcousens approved
  5. dcousens commented at 1:23 am on February 8, 2018: contributor
    light utACK
  6. practicalswift commented at 8:18 am on February 8, 2018: contributor
    Very nice! Concept ACK!
  7. in src/qt/optionsmodel.cpp:322 in cb6f615a8e outdated
    314@@ -315,7 +315,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
    315             break;
    316         case MapPortUPnP: // core option - can be changed on-the-fly
    317             settings.setValue("fUseUPnP", value.toBool());
    318-            MapPort(value.toBool());
    319+            if (value.toBool()) {
    320+                StartMapPort();
    321+            } else {
    322+                StopMapPort();
    


    laanwj commented at 2:08 pm on February 8, 2018:

    Probably call InterruptMapPort here too, before Stop, for consistency.

    Edit: Oh, you have Stop call Interrupt? That’s different from other [Start|Stop|Interrupt] constructions. As you probably know, the idea behind having a seperate interrupt is to have a two-stage (parallel) shutdown process, in which the interrupt can ask the subsystem to shut down, then Stop waits for it to really have stopped. Calling Stop without Interrupt could generally cause it to wait forever.


    theuni commented at 6:58 pm on February 8, 2018:
    Ok, I’ll move it out.

    laanwj commented at 7:34 pm on February 8, 2018:
    Sure - though if interrupt is idempotent there’s no problem in calling it in Stop too.
  8. laanwj commented at 2:14 pm on February 8, 2018: member
    utACK
  9. boost: drop boost threads for upnp f26866b9ca
  10. boost: remove useless threadGroup parameter from Discover ba91724948
  11. boost: drop boost threads from torcontrol 08272671d2
  12. boost: drop boost threads for [alert|block|wallet]notify 004f999946
  13. theuni force-pushed on Feb 8, 2018
  14. theuni commented at 7:59 pm on February 8, 2018: member

    Updated for @laanwj’s suggestion, though I didn’t see the second comment until I’d already pushed.

    Diff from before is trivial:

     0diff --git a/src/net.cpp b/src/net.cpp
     1index cd9a5e1..2019146 100644
     2--- a/src/net.cpp
     3+++ b/src/net.cpp
     4@@ -1562,3 +1562,2 @@ void StopMapPort()
     5     if(g_upnp_thread.joinable()) {
     6-        InterruptMapPort();
     7         g_upnp_thread.join();
     8diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
     9index ee8ba65..909be1c 100644
    10--- a/src/qt/optionsmodel.cpp
    11+++ b/src/qt/optionsmodel.cpp
    12@@ -320,2 +320,3 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
    13             } else {
    14+                InterruptMapPort();
    15                 StopMapPort();
    
  15. in src/net.cpp:1549 in 004f999946
    1546+void StartMapPort()
    1547 {
    1548-    static std::unique_ptr<boost::thread> upnp_thread;
    1549+    if (!g_upnp_thread.joinable()) {
    1550+        assert(!g_upnp_interrupt);
    1551+        g_upnp_thread = std::thread((std::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort)));
    


    Empact commented at 8:49 pm on February 8, 2018:
    Nit: extra parens. :P
  16. in src/net.cpp:1568 in 004f999946
    1576+        g_upnp_thread.join();
    1577+        g_upnp_interrupt.reset();
    1578     }
    1579 }
    1580 
    1581 #else
    


    Empact commented at 8:51 pm on February 8, 2018:
    Maybe worth commenting that this is the USE_UPNP disabled case?
  17. theuni commented at 9:26 pm on February 9, 2018: member
    Since there’s already an utACK, I’d prefer to leave @Empact’s nits alone, but I’ll be sure to include them if more changes are needed.
  18. jonasschnelli commented at 10:10 am on February 10, 2018: contributor
    utACK 004f9999464c7ef4a57b281dcbb407e5d193e798
  19. laanwj merged this on Feb 12, 2018
  20. laanwj closed this on Feb 12, 2018

  21. laanwj referenced this in commit 0dfc25f82a on Feb 12, 2018
  22. fanquake moved this from the "In progress" to the "Done" column in a project

  23. PastaPastaPasta referenced this in commit aeb79b51ec on Jun 13, 2020
  24. PastaPastaPasta referenced this in commit 9bc327dbb5 on Jun 13, 2020
  25. UdjinM6 referenced this in commit 224d0a3fb2 on Jun 13, 2020
  26. PastaPastaPasta referenced this in commit 360a4adbb1 on Jun 14, 2020
  27. random-zebra referenced this in commit 777638e7bc on Aug 27, 2020
  28. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me