The 2-Minute Rule for sleep
The 2-Minute Rule for sleep
Blog Article
atomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_compare_exchange_strongatomic_compare_exchange_strong_explicit
atomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_compare_exchange_strongatomic_compare_exchange_strong_explicit
This overload can be made use of to ignore spurious awakenings although expecting a selected ailment to be correct.
The very best-level operate might communicate its return benefit or an exception to the caller by using std::guarantee or by modifying shared variables (which may require synchronization, see std::mutex and std::atomic).
Even though the shared variable is atomic, it need to be modified while possessing the mutex to properly publish the modification to the waiting around thread.
The best-level perform may perhaps talk its return price or an exception into the caller via std::promise or by modifying shared variables (which may call for synchronization, see std::mutex and std::atomic).
The conventional endorses which the clock tied to abs_time be utilized to evaluate time; that clock is not required to be a monotonic clock. There are no guarantees regarding the behavior of this perform When the clock is adjusted discontinuously, but the existing implementations convert abs_time from Clock to std::chrono::system_clock and delegate to POSIX pthread_cond_timedwait so that the wait around honors changes on the process clock, although not on the consumer-presented Clock.
Even when notified under lock, overload (1) makes no guarantees in regards to the state with the connected predicate when returning Stages of sleep as a result of timeout.
atomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_compare_exchange_strongatomic_compare_exchange_strong_explicit
atomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_compare_exchange_strongatomic_compare_exchange_strong_explicit
If the long run is the results of a phone to std::async that used lazy analysis, this function returns quickly without waiting around.
atomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_compare_exchange_strongatomic_compare_exchange_strong_explicit
atomic_compare_exchange_weakatomic_compare_exchange_weak_explicitatomic_compare_exchange_strongatomic_compare_exchange_strong_explicit
This allows the perform to examine if halt has been requested for the duration of its execution, and return if it's got.
Should the std::long term acquired from std::async is just not moved from or sure to a reference, the destructor of the std::long term will block at the end of the complete expression right until the asynchronous operation completes, basically generating code for instance the subsequent synchronous: