concurrent_lru_cache::handle クラス

概要

concurrent_lru_cache に格納されている値への読み取り/書き込みアクセスを提供するクラス。

構文

template <typename key_type, typename value_type, typename value_functor_type>
class concurrent_lru_cache<key_type, value_type, value_functor_type>::handle;

実装では、concurrent_lru_cache::handle を実装定義のクラスにエイリアスされた typedef として宣言することがあります。

ヘッダー

#include "tbb/concurrent_lru_cache.h"

説明

handle は、concurrent_lru_cache コンテナーに格納されている値を参照するプロキシー・オブジェクトです。

有効な handle オブジェクトは、コンテナーが参照を保持している値を消去しないようにします。handle が再割り当てまたは破棄されると、参照は解放されます。値への最後の参照が解放されたら、コンテナーはその値を消去できます。

handle オブジェクトはコピーできません。代わりに、handle_move_t の暗黙の変換 (C++ 11 よりも前) またはムーブ・セマンティクス (C++ 11 以降) を利用して、参照を別の handle インスタンスへ転送できます。

メンバーおよび独立関数

namespace tbb {
    template <typename key_type,
              typename value_type,
              typename value_functor_type>
    class concurrent_lru_cache<key_type, value_type, value_functor_type>::handle {
    public:
        handle();
        ~handle();

        // C++11 以降でサポート
        handle(handle&& src);
        handle& operator=(handle&& src);

        // C++11 よりも前でサポート
        handle(handle_move_t m);
        handle& operator=(handle_move_t m);
        operator handle_move_t();
        friend handle_move_t move(handle& h);

        operator bool() const;
        value_type& value();

    private:
        void operator=(handle&);
        handle(handle&);
    };

}
次の表は、このクラスのメンバーの詳細な情報を提供します。
メンバー 説明
handle()

値を参照しない handle オブジェクトを構築します。

~handle()

concurrent_lru_cache に格納されている値への参照を解放します。

handle(handle&& src)

C++11 以降でサポート。ムーブ・コンストラクターは、concurrent_lru_cache に格納されている値への参照を src から新たに構築されたオブジェクトへ転送します。処理が完了すると、src は値を参照しなくなります。

handle& operator=(handle&& src)

C++11 以降でサポート。ムーブ代入演算子は、concurrent_lru_cache に格納されている値への参照を src から *this へ転送します。*this が保持する以前の参照は解放されます (存在する場合)。処理が完了すると、src は値を参照しなくなります。

戻り値: *this

handle(handle_move_t m)

handle& operator=(handle_move_t m)

C++11 よりも前でサポート。handle_move_t オブジェクトから handle オブジェクトの構築と割り当てを有効にします。以下に示す handle_move_t への変換演算子と併用することで、C++ ムーブ・セマンティクスを利用できない場合に、handle インスタンス間で concurrent_lru_cache アイテムへの参照を転送できるようにします。

operator handle_move_t()

friend handle_move_t move(handle& h)

C++11 よりも前でサポート。変換演算子と独立 friend 関数により、handle オブジェクトが保持する参照を handle_move_t 一時オブジェクトへ転送します。変換演算子は直接呼び出さずに、move 関数を使用します。処理が完了すると、handle オブジェクトは値を参照しなくなります。

戻り値: 指定された handle が以前に参照していた値を参照する handle_move_t オブジェクト。

operator bool() const

handle オブジェクトが値への参照を保持しているかどうかを確認します。

戻り値: *thisconcurrent_lru_cache に格納されている値への参照を保持している場合は true。その他の場合は false

value_type& value()

戻り値: concurrent_lru_cache に格納されている value_type オブジェクトへの参照。

値を参照しない handle オブジェクトに対してメソッドを 呼び出した場合の動作は不定です。