implement CreateThread with boost::thread #1738

pull laanwj wants to merge 2 commits into bitcoin:master from laanwj:2012_08_boostthread changing 9 files +40 −79
  1. laanwj commented at 4:43 PM on August 28, 2012: member

    I'm not sure why this wasn't done before.

    • Removes typedef of pthread_t on Windows, which fixes a native compile issue on mingw (@diapolo :-)
  2. jgarzik commented at 4:45 PM on August 28, 2012: contributor

    Good stuff. One nit: if we are touching this code, rename our CreateThread() to something not found in Windows or Linux standard libraries.

  3. laanwj commented at 4:47 PM on August 28, 2012: member

    Yes, good point. Any suggestions? StartThread? SpawnThread?

  4. Diapolo commented at 4:54 PM on August 28, 2012: none

    You are my hero :-D, what about just NewThread()? Well your ideas are also fine and I'm pro rename.

  5. in src/util.cpp:None in bd6db5608c outdated
    1298 | @@ -1299,3 +1299,15 @@ void RenameThread(const char* name)
    1299 |      (void)name;
    1300 |  #endif
    1301 |  }
    1302 | +
    1303 | +bool CreateThread(void(*pfn)(void*), void* parg)
    1304 | +{
    1305 | +    try
    1306 | +    {
    1307 | +        boost::thread(pfn, parg); // thread detaches when out of scope
    


    Diapolo commented at 4:55 PM on August 28, 2012:

    So all our threads are closed, even when for example we crash (thread unrelated)?


    laanwj commented at 5:16 PM on August 28, 2012:

    How do you mean that? We don't currently have any functionality to "catch" crashes (something like google breakpad could help there, but there's the not-so-small issue of accidentally sending private key data), I'm not sure how it's related to created threads.


    Diapolo commented at 7:59 PM on August 28, 2012:

    I refered to your comment here and just wanted to know if it includes a clean shutdown of threads started via CreateThread(), if the client crashes and if the crash is unrelated to the function here itself.

  6. jgarzik commented at 5:19 PM on August 28, 2012: contributor

    I'll let others choose the color of the bike shed ;p Just want to avoid clashing with existing symbols. It certainly caused confusion in the past.

  7. BitcoinPullTester commented at 10:09 AM on August 29, 2012: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/bd6db5608cd4e6a2ee77d6e409c8c3488d028cce for binaries and test log.

  8. Diapolo commented at 10:31 AM on August 29, 2012: none

    I tried that patch with my local build, no compilation problems and the resulting exe starts just fine.

  9. implement CreateThread with boost::thread
    I'm not sure why this wasn't done before.
    
    - Removes typedef of pthread_t on Windows, which fixes a native compile issue on mingw.
    61d8507140
  10. Rename CreateThread to NewThread
    Prevent clash with win32 API symbol
    4d1d94c56c
  11. laanwj commented at 6:27 PM on August 29, 2012: member

    Rebased and renamed the function to NewThread

  12. jgarzik commented at 6:29 PM on August 29, 2012: contributor

    ACK

  13. sipa commented at 12:25 AM on August 30, 2012: member

    ACK

  14. jgarzik referenced this in commit 8c7b6c05db on Sep 4, 2012
  15. jgarzik merged this on Sep 4, 2012
  16. jgarzik closed this on Sep 4, 2012

  17. laanwj deleted the branch on Apr 9, 2014
  18. sidhujag referenced this in commit cfce6fdf78 on Dec 1, 2017
  19. 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 15:16 UTC

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