Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::condition_variable_any

      From cppreference.com
      <cpp‎ |thread
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Condition variables
      condition_variable_any
      (C++11)
      (C++11)
      Semaphores
      Latches and Barriers
      (C++20)
      (C++20)
      Futures
      (C++11)
      (C++11)
      (C++11)
      Safe reclamation
      Hazard pointers
      Atomic types
      (C++11)
      (C++20)
      Initialization of atomic types
      (C++11)(deprecated in C++20)
      (C++11)(deprecated in C++20)
      Memory ordering
      (C++11)(deprecated in C++26)
      Free functions for atomic operations
      Free functions for atomic flags
       
       
      Defined in header<condition_variable>
      class condition_variable_any;
      (since C++11)

      Thecondition_variable_any class is a generalization ofstd::condition_variable. Whereasstd::condition_variable works only onstd::unique_lock<std::mutex>,condition_variable_any can operate on any lock that meets theBasicLockable requirements.

      Seestd::condition_variable for the description of the semantics of condition variables.

      The classstd::condition_variable_any is aStandardLayoutType. It is notCopyConstructible,MoveConstructible,CopyAssignable, orMoveAssignable.

      If the lock isstd::unique_lock<std::mutex>,std::condition_variable may provide better performance.

      Contents

      [edit]Member functions

      constructs the object
      (public member function)[edit]
      destructs the object
      (public member function)[edit]
      operator=
      [deleted]
      not copy-assignable
      (public member function)[edit]
      Notification
      notifies one waiting thread
      (public member function)[edit]
      notifies all waiting threads
      (public member function)[edit]
      Waiting
      blocks the current thread until the condition variable is awakened
      (public member function)[edit]
      blocks the current thread until the condition variable is awakened or after the specified timeout duration
      (public member function)[edit]
      blocks the current thread until the condition variable is awakened or until specified time point has been reached
      (public member function)[edit]

      [edit]Notes

      std::condition_variable_any can be used withstd::shared_lock in order to wait on astd::shared_mutex in shared ownership mode.

      A possible use forstd::condition_variable_any with customLockable types is to provide convenient interruptible waits: the custom lock operation would both lock the associated mutex as expected, and also perform the necessary setup to notify this condition variable when the interrupting signal is received.[1]

      [edit]See also

      provides a condition variable associated with astd::unique_lock
      (class)[edit]

      [edit]External links

      1. Anthony Williams (2012, 1st ed./ 2019, 2nd ed.), “C++ Concurrency in Action”, 9.2.4 “Interrupting a wait onstd::condition_variable_any”.
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/condition_variable_any&oldid=170074"

      [8]ページ先頭

      ©2009-2025 Movatter.jp