名前空間
変種
操作

std::atomic_ref<T>::wait

From cppreference.com
< cpp‎ | atomic‎ | atomic ref
 
 
並行性サポートライブラリ
スレッド
(C++11)
(C++20)
this_thread 名前空間
(C++11)
(C++11)
(C++11)
協調的なキャンセル
排他制御
(C++11)
汎用ロック管理
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
条件変数
(C++11)
セマフォ
ラッチとバリア
(C++20)
(C++20)
future
(C++11)
(C++11)
(C++11)
(C++11)
安全なメモリ解放 (Safe Reclamation)
(C++26)
ハザードポインタ
アトミック型
(C++11)
(C++20)
アトミック型の初期化
(C++11)(C++20で非推奨)
(C++11)(C++20で非推奨)
メモリオーダー
(C++11)(C++26で非推奨)
アトミック操作のためのフリー関数
アトミックフラグのためのフリー関数
 
 
void wait( value_type old, std::memory_order order =
                               std::memory_order_seq_cst ) const noexcept;
(C++26 以降 constexpr)

アトミックな待機操作を実行します。繰り返し以下のステップを実行するのと同等に動作します。

  • this->load(order) の値表現が old の値表現と等しいかを比較します。
    • If those are equal, then blocks until *this is notified by notify_one() or notify_all(), or the thread is unblocked spuriously.
    • それ以外の場合は、戻ります。

These functions are guaranteed to return only if value has changed, even if underlying implementation unblocks spuriously.

If order is not std::memory_order_relaxed, std::memory_order_consume, std::memory_order_acquire or std::memory_order_seq_cst, the behavior is undefined.

目次

[編集] パラメータ

old - atomic_ref のオブジェクトがもはや含まない値
order - 強制するメモリ順序制約

[編集] 注釈

この形式の変更検出は、単純なポーリングや純粋なスピンドックよりも効率的な場合が多いです。

ABA問題のため、old から別の値への一時的な変更、そして再び old に戻る変更は、見落とされる可能性があり、解除されない場合があります。

比較はビット列(std::memcmp に類似)であり、比較演算子は使用されません。オブジェクトの値表現に決して関与しないパディングビットは無視されます。

[編集]

[編集] 関連項目

アトミックオブジェクトを待機しているスレッドを少なくとも1つ通知する
(public member function) [編集]
アトミックオブジェクトを待機してブロックされている全てのスレッドに通知する
(public member function) [編集]
atomic_waitでブロックされているスレッドに通知する
(関数テンプレート) [編集]
atomic_waitでブロックされている全てのスレッドに通知する
(関数テンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)