|
The work library is intended to simplify the use of multithreading in the context of our software ecosystem.
This library is intended as a thin abstraction layer on top of a multithreading subsystem. The abstraction serves two purposes:
Because of the way multithreading subsystems work and because of the way they need to interact with each other in managing system resources, it is not generally practical for each client to use whatever threading system they like (e.g., TBB for one client, OpenMP for another).
The library defaults to maximum concurrency, i.e. it will attempt to use as many threads as available on the system. The default concurrency limit is established at static initialization time. The PXR_WORK_THREAD_LIMIT environment variable can be set to further limit concurrency, such as for example in a farm environment. PXR_WORK_THREAD_LIMIT must be set to an integer N, denoting one of the following:
The concurrency limit can be set programmatically, using for example:
or
It is preferable to use WorkSetMaximumConcurrencyLimit() when the desire to use the hardware to its fullest rather than specify the maximum concurrency limit manually.
Once you've initialized the library, you can now harness the awesome power of your multi-core machine. Here's a simple example of a Parallel For.
You can avoid the std::bind and provide your own functor object as well.