Namespaces
Variants

std::counting_semaphore<LeastMaxValue>:: try_acquire_for

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
template < class Rep, class Period >
bool try_acquire_for ( const std:: chrono :: duration < Rep, Period > & rel_time ) ;
(C++20 이후)

내부 카운터가 1 이상일 경우 원자적으로 감소시키려 시도하며, 그렇지 않을 경우 내부 카운터가 0 이상이 되어 성공적으로 감소시킬 수 있거나 rel_time 지속 시간이 초과될 때까지 블록합니다.

목차

사전 조건

(없음)

매개변수

rel_time - 함수가 실패하기 위해 반드시 대기해야 하는 최소 지속 시간

반환값

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

예외

std::system_error 또는 타임아웃 관련 예외를 발생시킬 수 있습니다.

참고 사항

실제로 이 함수는 rel_time 이상의 시간이 지나야 실패할 수 있습니다.

참고 항목

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