Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::lock_guard<Mutex>::lock_guard

      From cppreference.com
      <cpp‎ |thread‎ |lock guard
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      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)(since C++11)
      lock_guard( mutex_type& m,std::adopt_lock_t t);
      (2)(since C++11)
      lock_guard(const lock_guard&)= delete;
      (3)(since C++11)

      Acquires ownership of the given mutexm.

      1) Effectively callsm.lock().
      2) Acquires ownership of the mutexm without attempting to lock it. The behavior is undefined if the current thread does not hold a non-shared lock (i.e., a lock acquired bylock,try_lock,try_lock_for, ortry_lock_until) onm.
      3) Copy constructor is deleted.

      The behavior is undefined ifm is destroyed before thelock_guard object is.

      [edit]Parameters

      m - mutex to acquire ownership of
      t - tag parameter used to select non-locking version of the constructor

      [edit]Exceptions

      1) Throws any exceptions thrown bym.lock().
      2) Throws nothing.
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/lock_guard/lock_guard&oldid=161185"

      [8]ページ先頭

      ©2009-2025 Movatter.jp