Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::shared_mutex::try_lock_shared

      From cppreference.com
      <cpp‎ |thread‎ |shared mutex
       
       
      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
       
       
      bool try_lock_shared();
      (since C++17)

      Tries to lock the mutex in shared mode. Returns immediately. On successful lock acquisition returnstrue, otherwise returnsfalse.

      This function is allowed to fail spuriously and returnfalse even if the mutex is not currenly exclusively locked by any other thread.

      A priorunlock() operation on the same mutexsynchronizes-with (as defined instd::memory_order) this operation if it returnstrue.

      The behavior is undefined if the calling thread already owns the mutex in any mode.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      true if the lock was acquired successfully, otherwisefalse.

      [edit]Exceptions

      Throws nothing.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      locks the mutex, blocks if the mutex is not available
      (public member function)[edit]
      tries to lock the mutex, returns if the mutex is not available
      (public member function)[edit]
      unlocks the mutex (shared ownership)
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/shared_mutex/try_lock_shared&oldid=132662"

      [8]ページ先頭

      ©2009-2025 Movatter.jp