Namespaces
Variants

std::lock_guard<Mutex>:: lock_guard

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
std::lock_guard
Member functions
lock_guard::lock_guard
explicit lock_guard ( mutex_type & m ) ;
(1) (C++11 이후)
lock_guard ( mutex_type & m, std:: adopt_lock_t t ) ;
(2) (C++11 이후)
lock_guard ( const lock_guard & ) = delete ;
(3) (C++11 이후)

주어진 뮤텍스 m 의 소유권을 획득합니다.

1) 효과적으로 m. lock ( ) 를 호출합니다.
2) 뮤텍스 m 의 소유권을 획득하며, 이를 잠그려고 시도하지 않습니다. 현재 스레드가 m 에 대해 비공유 잠금(즉, lock , try_lock , try_lock_for , 또는 try_lock_until 으로 획득한 잠금)을 보유하고 있지 않은 경우 동작은 정의되지 않습니다.
3) 복사 생성자가 삭제되었습니다.

m lock_guard 객체보다 먼저 소멸될 경우 동작은 정의되지 않습니다.

매개변수

m - 소유권을 획득할 뮤텍스
t - 생성자의 비잠금 버전을 선택하기 위해 사용되는 태그 매개변수

예외

1) m. lock ( ) 가 발생시키는 모든 예외를 발생시킵니다.
2) 아무것도 던지지 않습니다.