Namespaces
Variants

std::counting_semaphore<LeastMaxValue>:: try_acquire

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_acquire ( ) noexcept ;
(C++20부터)

내부 카운터가 1 보다 클 경우 원자적으로 감소시키려 시도합니다; 0 와 관계없이 블로킹은 발생하지 않습니다.

반환값

true 만약 내부 카운터를 감소시켰다면, 그렇지 않으면 false 를 반환합니다.

참고 사항

구현체는 카운터가 0 보다 큰 경우에도 카운터를 감소시키지 못할 수 있습니다. 즉, 허위 실패(spuriously fail)하여 false 를 반환할 수 있습니다.

참고 항목

내부 카운터를 증가시키고 획득자들의 차단을 해제합니다
(public member function)
내부 카운터를 감소시키거나 감소시킬 수 있을 때까지 차단합니다
(public member function)
내부 카운터 감소를 시도하며, 최대 지정 시간 동안 차단합니다
(public member function)
내부 카운터 감소를 시도하며, 특정 시점까지 차단합니다
(public member function)