次の方法で共有


<thread> 関数

get_id

現在の実行スレッドを一意に識別します。

thread::id this_thread::get_id() noexcept;

戻り値

現在の実行のスレッドを一意に識別する thread::id 型のオブジェクト。

sleep_for

呼び出し元のスレッドをブロックします。

template <class Rep,
class Period>
inline void sleep_for(const chrono::duration<Rep, Period>& Rel_time);

パラメーター

Rel_time
期間を指定する duration オブジェクト。

解説

関数は、少なくとも、Rel_time で指定された時間、呼び出し元のスレッドをブロックします。 この関数では、例外がスローされません。

sleep_until

少なくとも指定された時間まで、呼び出し元スレッドをブロックします。

template <class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& Abs_time);

void sleep_until(const xtime *Abs_time);

パラメーター

Abs_time
特定の時点を表します。

解説

この関数では、例外がスローされません。

スワップ

2 つの thread オブジェクトの状態を交換します。

void swap(thread& Left, thread& Right) noexcept;

パラメーター


左側の thread オブジェクト。


右側の thread オブジェクト。

解説

関数は Left.swap(Right) を呼び出します。

yield

現在のスレッドが通常引き続き実行される場合であっても、他のスレッドを実行するようオペレーティング システムに通知します。

inline void yield() noexcept;

関連項目

<スレッド>