combinable テンプレート・クラス

概要

並列処理中に最終的な値にマージされるスレッドローカル値を保持するテンプレート・クラス。

構文

template<typename T> class combinable;

ヘッダー

#include "tbb/combinable.h"

説明

combinable<T> は、T 型の自身のローカル・インスタンスを各スレッドに提供します。

メンバー

namespace tbb {
        template <typename T>
        class combinable {
        public:
            combinable();
     
            template <typename FInit>
            combinable(FInit finit);}
     
            combinable(const combinable& other);
     
            ~combinable();
     
            combinable& operator=( const 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> combinable(FInit finit)

スレッドローカル要素が finit() の結果をコピーして作成される combinable を作成します。

注意

finit() 式は複数のスレッドで同時かつ安全に評価できなければなりません。スレッドローカル要素が作成されるたびに評価されます。

combinable( const combinable& other );

other のコピーを作成します。同じスレッドマップで other の各要素のコピーが含まれます。

~combinable()

*this のすべてのスレッドローカル要素を破棄します。

combinable& operator=( const combinable& other )

*thisother のコピーに設定します。

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&) の単項ファンクターでなければなりません。

効果: *thisT の各インスタンス x について f(x) を評価します。