Namespaces
Variants

std::latch:: try_wait

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(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
bool try_wait ( ) const noexcept ;
(C++20부터)

내부 카운터가 0에 도달한 경우에만 true 를 반환합니다. 이 함수는 내부 카운터가 0에 도달했더라도 매우 낮은 확률로 false 를 반환할 수 있습니다.

매개변수

(없음)

반환값

매우 낮은 확률로 false 를 반환하고, 그렇지 않은 경우 cnt == 0 입니다. 여기서 cnt 는 내부 카운터의 값입니다.

참고 사항

허위 결과가 허용되는 이유는 구현체가 std::memory_order_seq_cst 보다 더 완화된 메모리 순서를 사용할 수 있도록 하기 위함입니다.