62. Parallel min and max element algorithms using threads

This problem, and its solution, is similar in most ways to the previous one. What is slightly different is that the function concurrently executing on each thread must return a value that represents the minimum or the maximum element in the subrange. The pprocess() function template, shown as follows, is a higher-level function that implements the requested functionality generically, in the following way:

  • Its arguments are the first and one-past-last iterators to the range and a function object that processes the range that we will call f.
  • If the size of the range is smaller than a particular threshold, set to 10,000 elements here, it simply executes the function object f received ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.