|
STLdoc
STLdocumentation
|
The combinable<T> object is intended to provide thread-private copies of data, to perform lock-free thread-local sub-computations during parallel algorithms. At the end of the parallel operation, the thread-private sub-computations can then be merged into a final result. This class can be used instead of a shared variable, and can result in a performance improvement if there would otherwise be a lot of contention on that shared variable.
More...
#include <ppl.h>
Public Member Functions | |
| combinable () | |
Constructs a new combinable object. More... | |
| template<typename _Function > | |
| combinable (_Function _FnInitialize) | |
Constructs a new combinable object. More... | |
| combinable (const combinable &_Copy) | |
Constructs a new combinable object. More... | |
| combinable & | operator= (const combinable &_Copy) |
Assigns to a combinable object from another combinable object. More... | |
| ~combinable () | |
Destroys a combinable object. More... | |
| _Ty & | local () |
| Returns a reference to the thread-private sub-computation. More... | |
| _Ty & | local (bool &_Exists) |
| Returns a reference to the thread-private sub-computation. More... | |
| void | clear () |
| Clears any intermediate computational results from a previous usage. More... | |
| template<typename _Function > | |
| _Ty | combine (_Function _FnCombine) const |
| Computes a final value from the set of thread-local sub-computations by calling the supplied combine functor. More... | |
| template<typename _Function > | |
| void | combine_each (_Function _FnCombine) const |
| Computes a final value from the set of thread-local sub-computations by calling the supplied combine functor once per thread-local sub-computation. The final result is accumulated by the function object. More... | |
Private Member Functions | |
| __declspec (align(64)) struct _Node | |
| void | _InitNew () |
| void | _InitCopy (const combinable &_Copy) |
| _Node * | _FindLocalItem (unsigned long _Key, size_t *_PIndex) |
| _Node * | _AddLocalItem (unsigned long _Key, size_t _Index) |
Static Private Member Functions | |
| static _Ty | _DefaultInit () |
Private Attributes | |
| _Node *volatile * | _M_buckets |
| size_t | _M_size |
| std::tr1::function< _Ty()> | _M_fnInitialize |
The combinable<T> object is intended to provide thread-private copies of data, to perform lock-free thread-local sub-computations during parallel algorithms. At the end of the parallel operation, the thread-private sub-computations can then be merged into a final result. This class can be used instead of a shared variable, and can result in a performance improvement if there would otherwise be a lot of contention on that shared variable.
| _Ty | The data type of the final merged result. The type must have a copy constructor and a default constructor. |
For more information, see Parallel Containers and Objects.
|
inline |
Constructs a new combinable object.
The first constructor initializes new elements with the default constructor for the type _Ty .
The second constructor initializes new elements using the initialization functor supplied as the _FnInitialize parameter.
The third constructor is the copy constructor.
|
inlineexplicit |
Constructs a new combinable object.
| _Function | The type of the initialization functor object. |
| _FnInitialize | A function which will be called to initialize each new thread-private value of the type _Ty . It must support a function call operator with the signature _Ty (). |
The first constructor initializes new elements with the default constructor for the type _Ty .
The second constructor initializes new elements using the initialization functor supplied as the _FnInitialize parameter.
The third constructor is the copy constructor.
|
inline |
Constructs a new combinable object.
| _Copy | An existing combinable object to be copied into this one. |
The first constructor initializes new elements with the default constructor for the type _Ty .
The second constructor initializes new elements using the initialization functor supplied as the _FnInitialize parameter.
The third constructor is the copy constructor.
|
inline |
Destroys a combinable object.
|
inlineprivate |
|
inlineprivate |
|
inlinestaticprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
Clears any intermediate computational results from a previous usage.
|
inline |
Computes a final value from the set of thread-local sub-computations by calling the supplied combine functor.
| _Function | The type of the function object that will be invoked to combine two thread-local sub-computations. |
| _FnCombine | The functor that is used to combine the sub-computations. Its signature is T (T, T) or T (const T&, const T&), and it must be associative and commutative. |
|
inline |
Computes a final value from the set of thread-local sub-computations by calling the supplied combine functor once per thread-local sub-computation. The final result is accumulated by the function object.
| _Function | The type of the function object that will be invoked to combine a single thread-local sub-computation. |
| _FnCombine | The functor that is used to combine one sub-computation. Its signature is void (T) or void (const T&), and must be associative and commutative. |
|
inline |
Returns a reference to the thread-private sub-computation.
|
inline |
Returns a reference to the thread-private sub-computation.
| _Exists | A reference to a boolean. The boolean value referenced by this argument will be set to true if the sub-computation already existed on this thread, and set to false if this was the first sub-computation on this thread. |
|
inline |
Assigns to a combinable object from another combinable object.
| _Copy | An existing combinable object to be copied into this one. |
combinable object.
|
private |
|
private |
|
private |
1.8.8