When striving for performance, programming in terms of threads can be a poor way to do multithreaded programming. It is much better to formulate your program in terms of logical tasks, not threads, for several reasons.
Matching parallelism to available resources
Faster task startup and shutdown
More efficient evaluation order
Perform computations on items in a data set, where the computation on an item uses results from computations on predecessor items.
The dependences between computations form an acyclic graph.
Unless otherwise stated, the thread safety rules for the library are as follows:
Two threads can invoke a method or function concurrently on different objects, but not the same object.
It is unsafe for two threads to invoke concurrently methods or functions on the same object.
Specify that a parallel loop should recursively split its range until it cannot be subdivided further.
View set of items in a container as a recursively divisible range.
A Container Range is a Range with the further requirements listed in below.
Concurrent invocation of these operations on the same instance is not safe.
A base class for all graph nodes.
A node that encapsulates a collection of other nodes as a first class graph node. The use of composite_node requires C++11 support. On Microsoft Windows*, at least Visual Studio 2013 is required.