Software Open Access

A C++17 Thread Pool for High-Performance Scientific Computing

Shoshany, Barak


JSON Export

{
  "files": [
    {
      "links": {
        "self": "https://zenodo.org/api/files/ff97ab24-3500-4eeb-a5de-5a83a1cf3bea/bshoshany/thread-pool-v3.3.0.zip"
      }, 
      "checksum": "md5:de781fc0b935d9cd4983718a307ff4a6", 
      "bucket": "ff97ab24-3500-4eeb-a5de-5a83a1cf3bea", 
      "key": "bshoshany/thread-pool-v3.3.0.zip", 
      "type": "zip", 
      "size": 60179
    }
  ], 
  "owners": [
    220046
  ], 
  "doi": "10.5281/zenodo.6959270", 
  "stats": {
    "version_unique_downloads": 13.0, 
    "unique_views": 152.0, 
    "views": 160.0, 
    "version_views": 736.0, 
    "unique_downloads": 2.0, 
    "version_unique_views": 678.0, 
    "volume": 120358.0, 
    "version_downloads": 23.0, 
    "downloads": 2.0, 
    "version_volume": 621460.0
  }, 
  "links": {
    "doi": "https://doi.org/10.5281/zenodo.6959270", 
    "conceptdoi": "https://doi.org/10.5281/zenodo.4742687", 
    "bucket": "https://zenodo.org/api/files/ff97ab24-3500-4eeb-a5de-5a83a1cf3bea", 
    "conceptbadge": "https://zenodo.org/badge/doi/10.5281/zenodo.4742687.svg", 
    "html": "https://zenodo.org/record/6959270", 
    "latest_html": "https://zenodo.org/record/6959270", 
    "badge": "https://zenodo.org/badge/doi/10.5281/zenodo.6959270.svg", 
    "latest": "https://zenodo.org/api/records/6959270"
  }, 
  "conceptdoi": "10.5281/zenodo.4742687", 
  "created": "2022-08-03T18:25:12.845696+00:00", 
  "updated": "2022-08-04T01:49:20.000476+00:00", 
  "conceptrecid": "4742687", 
  "revision": 3, 
  "id": 6959270, 
  "metadata": {
    "access_right_category": "success", 
    "doi": "10.5281/zenodo.6959270", 
    "description": "v3.3.0 (2022-08-03)\n<ul>\n<li><code>BS_thread_pool.hpp</code>:<ul>\n<li>The public member variable <code>paused</code> of <code>BS::thread_pool</code> has been made private for future-proofing (in case future versions implement a more involved pausing mechanism) and better encapsulation. It is now accessible only via the <code>pause()</code>, <code>unpause()</code>, and <code>is_paused()</code> member functions. In other words:<ul>\n<li>Replace <code>pool.paused = true</code> with <code>pool.pause()</code>.</li>\n<li>Replace <code>pool.paused = false</code> with <code>pool.unpause()</code>.</li>\n<li>Replace <code>if (pool.paused)</code> (or similar) with <code>if (pool.is_paused())</code>.</li>\n</ul>\n</li>\n<li>The public member variable <code>f</code> of <code>BS::multi_future</code> has been renamed to <code>futures</code> for clarity, and has been made private for encapsulation and simplification purposes. Instead of operating on the vector <code>futures</code> itself, you can now use the <code>[]</code> operator of the <code>BS::multi_future</code> to access the future at a specific index directly, or the <code>push_back()</code> member function to append a new future to the list. The <code>size()</code> member function tells you how many futures are currently stored in the object.</li>\n<li>The explicit casts of <code>std::endl</code> and <code>std::flush</code>, added in v3.2.0 to enable flushing a <code>BS::synced_stream</code>, caused ODR (One Definition Rule) violations if <code>BS_thread_pool.hpp</code> was included in two different translation units, since they were mistakenly not defined as <code>inline</code>. To fix this, I decided to make them static members of <code>BS::synced_stream</code> instead of global variables, which also makes the code better organized in my opinion. These objects can now be accessed as <code>BS::synced_stream::endl</code> and <code>BS::synced_stream::flush</code>. I also added an example for how to use them in <code>README.md</code>. See <a href=\"https://github.com/bshoshany/thread-pool/issues/64\">#64</a>.</li>\n</ul>\n</li>\n<li><code>BS_thread_pool_light.hpp</code>:<ul>\n<li>This package started out as a very lightweight thread pool, but over time has expanded to include many additional features, and at the time of writing it has a total of 340 lines of code, including all the helper classes. Therefore, I have decided to bundle a light version of the thread pool in a separate and stand-alone header file, <code>BS_thread_pool_light.hpp</code>, with only 170 lines of code (half the size of the full package). This file does not contain any of the helper classes, only a new <code>BS::thread_pool_light</code> class, which is a minimal thread pool with only the 5 most basic member functions:<ul>\n<li><code>get_thread_count()</code></li>\n<li><code>push_loop()</code></li>\n<li><code>push_task()</code></li>\n<li><code>submit()</code></li>\n<li><code>wait_for_tasks()</code></li>\n</ul>\n</li>\n<li>A separate test program <code>BS_thread_pool_light_test.cpp</code> tests only the features of the lightweight <code>BS::thread_pool_light</code> class. In the spirit of minimalism, it does not generate a log file and does not do any benchmarks.</li>\n<li>To be perfectly clear, each header file is 100% stand-alone. If you wish to use the full package, you only need <code>BS_thread_pool.hpp</code>, and if you wish to use the light version, you only need <code>BS_thread_pool_light.hpp</code>. Only a single header file needs to be included in your project.</li>\n</ul>\n</li>\n</ul>", 
    "license": {
      "id": "MIT"
    }, 
    "title": "A C++17 Thread Pool for High-Performance Scientific Computing", 
    "notes": "If you use this package in published research, please cite it as follows.", 
    "relations": {
      "version": [
        {
          "count": 11, 
          "index": 10, 
          "parent": {
            "pid_type": "recid", 
            "pid_value": "4742687"
          }, 
          "is_last": true, 
          "last_child": {
            "pid_type": "recid", 
            "pid_value": "6959270"
          }
        }
      ]
    }, 
    "version": "v3.3.0", 
    "publication_date": "2021-05-03", 
    "creators": [
      {
        "orcid": "0000-0003-2222-127X", 
        "name": "Shoshany, Barak"
      }
    ], 
    "access_right": "open", 
    "resource_type": {
      "type": "software", 
      "title": "Software"
    }, 
    "related_identifiers": [
      {
        "scheme": "url", 
        "identifier": "https://github.com/bshoshany/thread-pool/tree/v3.3.0", 
        "relation": "isSupplementTo"
      }, 
      {
        "scheme": "doi", 
        "identifier": "10.5281/zenodo.4742687", 
        "relation": "isVersionOf"
      }
    ]
  }
}
736
23
views
downloads
All versions This version
Views 736160
Downloads 232
Data volume 621.5 kB120.4 kB
Unique views 678152
Unique downloads 132

Share

Cite as