std::atomic_flag::wait
From cppreference.com
< cpp | atomic | atomic flag
void wait( bool old, std::memory_order order = std::memory_order_seq_cst ) const noexcept; |
(1) | (C++20以降) (C++26 以降 constexpr) |
| void wait( bool old, std::memory_order order = |
(2) | (C++20以降) |
アトミックな待機操作を実行します。繰り返し以下のステップを実行するのと同等に動作します。
- Compare this->test(order) with that of 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 | - | the value to check the atomic_flag's object no longer contains |
| order | - | 強制するメモリ順序制約 |
[編集] 注釈
この形式の変更検出は、単純なポーリングや純粋なスピンドックよりも効率的な場合が多いです。
ABA問題のため、old から別の値への一時的な変更、そして再び old に戻る変更は、見落とされる可能性があり、解除されない場合があります。
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 関連項目
| (C++20) |
アトミックオブジェクトを待機しているスレッドを少なくとも1つ通知する (public member function) |
| (C++20) |
アトミックオブジェクトを待機してブロックされている全てのスレッドに通知する (public member function) |
| (C++20) |
atomic_flag_waitでブロックされているスレッドに通知する (function) |
| (C++20) |
atomic_flag_waitでブロックされている全てのスレッドに通知する (function) |