std::condition_variable_any
From cppreference.com
| ヘッダ <condition_variable> で定義 |
||
| class condition_variable_any; |
(C++11以降) | |
condition_variable_anyクラスは、std::condition_variableの汎化です。std::condition_variableがstd::unique_lock<std::mutex>でのみ動作するのに対し、condition_variable_anyはBasicLockable要件を満たすあらゆるロックで操作できます。
条件変数のセマンティクスの説明については、std::condition_variableを参照してください。
クラスstd::condition_variable_anyはStandardLayoutTypeです。これはCopyConstructible、MoveConstructible、CopyAssignable、またはMoveAssignableではありません。
ロックがstd::unique_lock<std::mutex>である場合、std::condition_variableの方がパフォーマンスが良い場合があります。
目次 |
[編集] メンバ関数
| オブジェクトを構築する (public member function) | |
| オブジェクトを破棄する (public member function) | |
| operator= [削除] |
コピー代入不可 (public member function) |
通知 | |
| 待機中のスレッドを1つ通知します。 (public member function) | |
| 待機しているすべてのスレッドに通知します (public member function) | |
待機 | |
| 条件変数が通知されるまで現在のスレッドをブロックする (public member function) | |
| 指定されたタイムアウト期間後、または条件変数(condition variable)が起動されるまで、現在のスレッドをブロックする。 (public member function) | |
| 指定された時刻に達するか、または条件変数(condition variable)が起動されるまで、現在のスレッドをブロックする。 (public member function) | |
[編集] 注記
std::condition_variable_anyは、std::shared_lockと組み合わせて、std::shared_mutexを共有所有モードで待機するために使用できます。
カスタムLockable型でstd::condition_variable_anyを使用する1つの可能性は、中断可能な待機を便利に提供することです。カスタムロック操作は、関連するミューテックスを期待どおりにロックするだけでなく、割り込みシグナルが受信されたときにこの条件変数に通知するための必要なセットアップも実行します。[1]
[編集] 関連項目
| (C++11) |
std::unique_lock と関連付けられた条件変数を提供する (クラス) |
[編集] 外部リンク
|