名前空間
変種
操作

std::atomic_flag::wait

From cppreference.com
< cpp‎ | atomic‎ | atomic flag
 
 
並行性サポートライブラリ
スレッド
(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( 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 =

               std::memory_order_seq_cst ) const volatile noexcept;
(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 に戻る変更は、見落とされる可能性があり、解除されない場合があります。


[編集]

[編集] 関連項目

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