httpserver: drop boost (#8023 dependency) #8421

pull theuni wants to merge 3 commits into bitcoin:master from theuni:http-thread changing 2 files +33 −35
  1. theuni commented at 11:14 PM on July 28, 2016: member

    This is a prerequisite for #8023. The httpserver depends on boost::thread::try_join_for, which has no equivalent in std::thread. Rather than going to the effort of porting try_join_for to our interruptible thread wrapper, it's simpler and more efficient to not rely on it in the first place.

    755aa05174e06effd758eeb78c5af9fb465e9611 replaces the try_join_for with a future which is set when the callable function finishes. The flow is otherwise the same. I tested that this works as intended by inserting sleeps to force the event_base_loopbreak.

    d3773ca9aeb0d2f12dc0c5a0726778050c8cb455 Fixes an incompatibility between boost and std threads. This was likely to be an issue in the future with boost anyway.

    Lastly, with the incompatibilities removed, just go ahead and switch to std::thread since there's need for interruption here.

  2. httpserver: use a future rather than relying on boost's try_join_for 755aa05174
  3. httpserver: explicitly detach worker threads
    When using std::thread in place of boost::thread, letting the threads destruct
    results in a std::terminate. According to the docs, the same thing should be
    be happening in later boost versions:
    http://www.boost.org/doc/libs/1_55_0/doc/html/thread/thread_management.html#thread.thread_management.thread.destructor
    
    I'm unsure why this hasn't blown up already, but explicitly detaching can't
    hurt.
    d3773ca9ae
  4. httpserver: replace boost threads with std
    along with mutex/condvar/bind/etc.
    
    httpserver handles its own interruption, so there's no reason not to use std
    threading.
    
    While we're at it, may as well kill the BOOST_FOREACH's as well.
    7e87033447
  5. sipa commented at 11:43 PM on July 28, 2016: member

    Concept ACK

  6. in src/httpserver.cpp:None in 7e87033447
     186 | @@ -189,7 +187,7 @@ static bool ClientAllowed(const CNetAddr& netaddr)
     187 |  {
     188 |      if (!netaddr.IsValid())
     189 |          return false;
     190 | -    BOOST_FOREACH (const CSubNet& subnet, rpc_allow_subnets)
     191 | +    for(const CSubNet& subnet : rpc_allow_subnets)
    


    dcousens commented at 1:19 AM on July 29, 2016:

    nit: s/for(/for (/ for consistency

  7. dcousens commented at 1:20 AM on July 29, 2016: contributor

    concept && utACK 7e87033

  8. laanwj added the label Refactoring on Jul 29, 2016
  9. in src/httpserver.cpp:None in 7e87033447
     485 | @@ -482,15 +486,11 @@ void StopHTTPServer()
     486 |          // master that appears to be solved, so in the future that solution
     487 |          // could be used again (if desirable).
     488 |          // (see discussion in https://github.com/bitcoin/bitcoin/pull/6990)
     489 | -#if BOOST_VERSION >= 105000
     490 | -        if (!threadHTTP.try_join_for(boost::chrono::milliseconds(2000))) {
     491 | -#else
     492 | -        if (!threadHTTP.timed_join(boost::posix_time::milliseconds(2000))) {
     493 | -#endif
     494 | +        if (threadResult.valid() && threadResult.wait_for(std::chrono::milliseconds(2000)) == std::future_status::timeout) {
    


    laanwj commented at 6:17 AM on July 29, 2016:

    Nice solution!

  10. laanwj commented at 6:19 AM on July 29, 2016: member

    utACK 7e87033

  11. laanwj merged this on Jul 29, 2016
  12. laanwj closed this on Jul 29, 2016

  13. laanwj referenced this in commit b77bb95b3c on Jul 29, 2016
  14. codablock referenced this in commit 784153102c on Sep 19, 2017
  15. zkbot referenced this in commit fb2f98e00b on Oct 23, 2017
  16. codablock referenced this in commit 9df93b6f86 on Dec 29, 2017
  17. codablock referenced this in commit c03c42116b on Jan 8, 2018
  18. sickpig referenced this in commit 46b5b86be5 on Mar 9, 2018
  19. sickpig referenced this in commit dadc2880a1 on Mar 9, 2018
  20. sickpig referenced this in commit 6d4a55878a on Mar 12, 2018
  21. sickpig referenced this in commit 6db640a393 on Mar 12, 2018
  22. sickpig referenced this in commit 76cf243311 on Mar 12, 2018
  23. sickpig referenced this in commit 4428056252 on Mar 12, 2018
  24. marlengit referenced this in commit 297ac08c3a on Sep 25, 2018
  25. andvgal referenced this in commit b29ac790c8 on Jan 6, 2019
  26. zkbot referenced this in commit faf3825eed on Sep 30, 2020
  27. zkbot referenced this in commit a983344931 on Oct 1, 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: 2026-04-13 21:15 UTC

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