Namespaces
Variants

std::shared_lock<Mutex>:: try_lock_until

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 Clock, class Duration >
bool try_lock_until ( const std:: chrono :: time_point < Clock,Duration > & timeout_time ) ;
(C++14 이후)

연결된 뮤텍스를 공유 모드로 잠그려 시도합니다. 지정된 timeout_time 에 도달하거나 잠금이 획득될 때까지(둘 중 먼저 도래하는 시점) 블록합니다. 잠금 획득에 성공하면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다. timeout_time 이 도달한 시점보다 더 오래 블록될 수 있습니다.

효과적으로 mutex ( ) - > try_lock_shared_until ( timeout_time ) 를 호출합니다.

std::system_error 는 연결된 뮤텍스가 없거나 뮤텍스가 이미 잠겨 있는 경우 발생합니다.

Clock Clock 요구 사항을 충족해야 합니다. Mutex SharedTimedLockable 요구 사항을 충족하지 않으면 동작은 정의되지 않습니다. std:: chrono :: is_clock_v < Clock > false 인 경우 프로그램의 형식이 올바르지 않습니다. (C++20부터)

목차

매개변수

timeout_time - 블록이 수행될 최대 시간 지점

반환값

true 뮤텍스의 소유권을 성공적으로 획득한 경우, false 그렇지 않은 경우.

예외

  • mutex ( ) - > try_lock_shared_for ( timeout_time ) 에 의해 발생하는 모든 예외.

예제

참고 항목

연결된 뮤텍스를 잠금
(public member function)
연결된 뮤텍스를 잠그려 시도
(public member function)
지정된 시간 동안 연결된 뮤텍스를 잠그려 시도
(public member function)
연결된 뮤텍스를 잠금 해제
(public member function)
연결된 TimedLockable 뮤텍스를 잠그려 시도(즉, 소유권 획득), 지정된 시간 지점에 도달할 때까지 뮤텍스를 사용할 수 없는 경우 반환
( std::unique_lock<Mutex> 의 public member function)