Published May 3, 2021
| Version v3.3.0
Software
Open
A C++17 Thread Pool for High-Performance Scientific Computing
Creators
Description
v3.3.0 (2022-08-03)
BS_thread_pool.hpp
:- The public member variable
paused
ofBS::thread_pool
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 thepause()
,unpause()
, andis_paused()
member functions. In other words:- Replace
pool.paused = true
withpool.pause()
. - Replace
pool.paused = false
withpool.unpause()
. - Replace
if (pool.paused)
(or similar) withif (pool.is_paused())
.
- Replace
- The public member variable
f
ofBS::multi_future
has been renamed tofutures
for clarity, and has been made private for encapsulation and simplification purposes. Instead of operating on the vectorfutures
itself, you can now use the[]
operator of theBS::multi_future
to access the future at a specific index directly, or thepush_back()
member function to append a new future to the list. Thesize()
member function tells you how many futures are currently stored in the object. - The explicit casts of
std::endl
andstd::flush
, added in v3.2.0 to enable flushing aBS::synced_stream
, caused ODR (One Definition Rule) violations ifBS_thread_pool.hpp
was included in two different translation units, since they were mistakenly not defined asinline
. To fix this, I decided to make them static members ofBS::synced_stream
instead of global variables, which also makes the code better organized in my opinion. These objects can now be accessed asBS::synced_stream::endl
andBS::synced_stream::flush
. I also added an example for how to use them inREADME.md
. See #64.
- The public member variable
BS_thread_pool_light.hpp
:- 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,
BS_thread_pool_light.hpp
, 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 newBS::thread_pool_light
class, which is a minimal thread pool with only the 5 most basic member functions:get_thread_count()
push_loop()
push_task()
submit()
wait_for_tasks()
- A separate test program
BS_thread_pool_light_test.cpp
tests only the features of the lightweightBS::thread_pool_light
class. In the spirit of minimalism, it does not generate a log file and does not do any benchmarks. - To be perfectly clear, each header file is 100% stand-alone. If you wish to use the full package, you only need
BS_thread_pool.hpp
, and if you wish to use the light version, you only needBS_thread_pool_light.hpp
. Only a single header file needs to be included in your project.
- 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,
Notes
Files
bshoshany/thread-pool-v3.3.0.zip
Files
(60.2 kB)
Name | Size | Download all |
---|---|---|
md5:de781fc0b935d9cd4983718a307ff4a6
|
60.2 kB | Preview Download |
Additional details
Related works
- Is supplement to
- https://github.com/bshoshany/thread-pool/tree/v3.3.0 (URL)