4 ms·
Generally, do not use raw threads. They are a building block for higher level abstractions like task queues, pipelines, futures... which lend themselves to hi
by beached_whale 9y ago
Generally, do not use raw threads. They are a building block for higher level abstractions like task queues, pipelines, futures... which lend themselves to higher level algorithms like your sorts, filters, find, map, reduce, map_reduce...
C++17 gets a lot of this with much of the algorithms header getting parallel/vectorized versions. But it doesn't have a task stealing work queue or something like then to pass the value when it completes. Boost has a version now that does though and this lets you have the next function called when done instead of waiting and blocking.
But if you spend your time in the thread zone you are probably putting too much thought into threading and not the problem you are solving. Plus, using a task queue can yield really good results for lower level algorithms.