並列処理中に最終的な値にマージされるスレッドローカル値を保持するテンプレート・クラス。
template<typename T> class combinable;
#include "tbb/combinable.h"
combinable<T> は、T 型の自身のローカル・インスタンスを各スレッドに提供します。
namespace tbb { template <typename T> class combinable { public: combinable(); template <typename FInit> explicit combinable(FInit finit); combinable(const combinable& other); // C++11 からサポート combinable(combinable&& other); ~combinable(); combinable& operator=( const combinable& other); // C++11 からサポート combinable& operator=( combinable&& other); void clear(); T& local(); T& local(bool & exists); template<typename FCombine> T combine(FCombine fcombine); template<typename Func> void combine_each(Func f); }; }
メンバー | 説明 |
---|---|
combinable() | T のスレッド・ローカル・インスタンスがデフォルト設定を使用して作成される combinable を作成します。 |
template<typename FInit> explicit combinable(FInit finit) | スレッドローカル要素が finit() の結果をコピーして作成される combinable を作成します。 注意finit() 式は複数のスレッドで同時かつ安全に評価できなければなりません。スレッドローカル要素が作成されるたびに評価されます。 |
combinable( const combinable& other ); | other のコピーを作成します。同じスレッドマップで other の各要素のコピーが含まれます。 |
combinable( combinable&& other ); | C++11 からサポート。other のコンテンツをそのまま移動することにより combinable を構築します。other は無指定の状態のままですが、安全に破棄することができます。 |
~combinable() | *this のすべてのスレッドローカル要素を破棄します。 |
combinable& operator=( const combinable& other ) | *this を other のコピーに設定します。 |
combinable& operator=( combinable&& other ) | C++11 からサポート。other のコンテンツをそのまま *this に移動します。other は無指定の状態のままですが、安全に破棄することができます。 |
void clear() | *this からすべての要素を削除します。 |
T& local() | スレッドローカル要素が存在しない場合、スレッドローカル要素を作成します。 戻り値: スレッドローカル要素への参照。 |
T& local( bool& exists ) | 要素が現在のスレッドに存在していた場合は exists が true に設定され、存在していなかった場合は false に設定されることを除いて、local() に似ています。 戻り値: スレッドローカル要素への参照。 |
template<typename FCombine>T combine(FCombine fcombine) | 要件: fcombine 引数は、署名 T(T,T) または T(const T&,const T&) の結合バイナリー・ファンクターでなければなりません。 効果: バイナリー・ファンクター fcombine を使用してすべての要素のリダクションを計算します。要素がない場合、スレッドローカル要素の作成と同じ規則を使用して結果を作成します。 戻り値: リダクションの結果。 |
template<typename Func> void combine_each(Func f) | 要件: f 引数は、署名 void(T) または void(const T&) の単項ファンクターでなければなりません。 効果: *this の T の各インスタンス x について f(x) を評価します。 |