std::atomic_ref<T>::wait
From cppreference.com
< cpp | atomic | atomic ref
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) | |
| (C++20) |
atomic_waitでブロックされているスレッドに通知する (関数テンプレート) |
| (C++20) |
atomic_waitでブロックされている全てのスレッドに通知する (関数テンプレート) |