this_thread 名前空間

概要

this_thread 名前空間には、スレッド化に関連するグローバル関数が含まれます。

メンバー

 namespace std {
     namespace this_thread {
         thread::id get_id();
         void yield();
         void sleep( const tbb::tick_count::interval_t& );
     }
 }
		
次の表は、この名前空間の関数の詳細な情報を提供します。
メンバー 説明
thread::id get_id()

戻り値: 現在のスレッドの ID。

void yield()

別のスレッドが実行できるように現在のスレッドを休止します。

void sleep_for( const tick_count::interval_t & i)

現在のスレッドを少なくとも i 秒間ブロックします。

サンプル

    void Foo() {
        // 30 秒スリープ
        std::this_thread::sleep_for( tbb::tick_count::interval_t(30) );
    }