There is a newer version of this record available.

Software Open Access

bshoshany/thread-pool: thread-pool v2.0.0

Barak Shoshany

  • v2.0.0 (2021-08-14)
    • From now on, version numbers will adhere to the Semantic Versioning specification in the format major.minor.patch.
    • A file named thread_pool_test.cpp has been added to the package. It will perform automated tests of all aspects of the package, and benchmark some multithreaded matrix operations. Please run it on your system and submit a bug report if any of the tests fail. In addition, the code is thoroughly documented, and is meant to serve as an extensive example of how to properly use the package.
    • The package is now available through vcpkg. Instructions for how to install it have been added to See this pull request.
    • The package now defines a macro THREAD_POOL_VERSION, which returns the version number and release date of the thread pool library as a string.
    • parallelize_loop() has undergone some major changes (and is now incompatible with v1.x):
      • The second argument is now the index after the last index, instead of the last index itself. This is more consistent with C++ conventions (e.g. standard library algorithms) where the range is always [first, last). For example, for an array with n indices, instead of parallelize_loop(0, n - 1, ...) you should now write parallelize_loop(0, n, ...).
      • The loop function is now only called once per block, instead of once per index, as was the case before. This should provide a performance boost due to significantly reducing the number of function calls, and it also allows you to conserve resources by using them only once per block instead of once per index (an example can be found in the random_matrix_generator class in thread_pool_test.cpp). It also means that loop now takes two arguments: the first index in the block and the index after the last index in the block. Thus, loop(start, end) should typically involve a loop of the form for (T i = start; i < end; i++).
      • The first and last indices can now be of two different integer types. Previously, parallelize_loop(0, i, ...) did not work if i was not an int, because 0 was interpreted as int, and the two arguments had to be of the same type. Therefore, one had to use casting, e.g. parallelize_loop((size_t)0, i), to make it work. Now this is no longer necessary; the common type is inferred automatically using std::common_type_t.
Files (33.6 kB)
Name Size
33.6 kB Download
All versions This version
Views 741262
Downloads 233
Data volume 621.5 kB100.8 kB
Unique views 683248
Unique downloads 133


Cite as