olp-cpp-sdk  1.22.0
Public Types | Public Member Functions | List of all members
std::shared_lock< Mutex > Class Template Reference

A shared mutex wrapper that supports timed lock operations and non-exclusive sharing by multiple threads. More...

#include <shared_mutex.h>

Public Types

typedef Mutex mutex_type
 A typedef for the mutex type.
 

Public Member Functions

 shared_lock (mutex_type &__m)
 Creates a shared_lock instance and locks the associated mutex. More...
 
 shared_lock (mutex_type &__m, defer_lock_t) noexcept
 Creates a shared_lock instance and does not lock the associated mutex. More...
 
 shared_lock (mutex_type &__m, try_to_lock_t)
 Creates a shared_lock instance and tries to lock the associated mutex without blocking. More...
 
 shared_lock (mutex_type &__m, adopt_lock_t)
 Creates a shared_lock instance and assumes that the calling thread already owns the associated mutex. More...
 
template<typename _Clock , typename _Duration >
 shared_lock (mutex_type &__m, const chrono::time_point< _Clock, _Duration > &__abs_time)
 Creates a shared_lock instance and tries to lock the associated mutex until the specified absolute time has passed. More...
 
template<typename _Rep , typename _Period >
 shared_lock (mutex_type &__m, const chrono::duration< _Rep, _Period > &__rel_time)
 Creates a shared_lock instance and tries to lock the associated mutex until the specified duration has passed. More...
 
 shared_lock (shared_lock const &)=delete
 
shared_lockoperator= (shared_lock const &)=delete
 
 shared_lock (shared_lock &&__sl) noexcept
 Creates a shared_lock instance based on the other shared lock. More...
 
shared_lockoperator= (shared_lock &&__sl) noexcept
 The default move assignment operator. More...
 
void lock ()
 Takes ownership of the associated mutex. More...
 
bool try_lock ()
 Tries to take ownership of the mutex without blocking. More...
 
template<typename _Rep , typename _Period >
bool try_lock_for (const chrono::duration< _Rep, _Period > &__rel_time)
 Tries to take shared ownership of the mutex and blocks it until the specified time elapses. More...
 
template<typename _Clock , typename _Duration >
bool try_lock_until (const chrono::time_point< _Clock, _Duration > &__abs_time)
 Tries to take shared ownership of the mutex and blocks it until the absolute time has passed. More...
 
void unlock ()
 Releases the ownership of the mutex from the calling thread. More...
 
void swap (shared_lock &__u) noexcept
 Exchanges the data members of two shared_lock instances. More...
 
mutex_typerelease () noexcept
 Disassociates the mutex without unlocking. More...
 
bool owns_lock () const noexcept
 Checks whether the lock owns its associated mutex. More...
 
 operator bool () const noexcept
 Checks whether the lock owns its associated mutex. More...
 
mutex_typemutex () const noexcept
 Gets a pointer to the associated mutex. More...
 

Detailed Description

template<typename Mutex>
class std::shared_lock< Mutex >

A shared mutex wrapper that supports timed lock operations and non-exclusive sharing by multiple threads.

Constructor & Destructor Documentation

◆ shared_lock() [1/7]

template<typename Mutex >
std::shared_lock< Mutex >::shared_lock ( mutex_type __m)
inlineexplicit

Creates a shared_lock instance and locks the associated mutex.

Parameters
__mThe associated mutex.

◆ shared_lock() [2/7]

template<typename Mutex >
std::shared_lock< Mutex >::shared_lock ( mutex_type __m,
defer_lock_t   
)
inlinenoexcept

Creates a shared_lock instance and does not lock the associated mutex.

Parameters
__mThe associated mutex.

◆ shared_lock() [3/7]

template<typename Mutex >
std::shared_lock< Mutex >::shared_lock ( mutex_type __m,
try_to_lock_t   
)
inline

Creates a shared_lock instance and tries to lock the associated mutex without blocking.

Parameters
__mThe associated mutex.

◆ shared_lock() [4/7]

template<typename Mutex >
std::shared_lock< Mutex >::shared_lock ( mutex_type __m,
adopt_lock_t   
)
inline

Creates a shared_lock instance and assumes that the calling thread already owns the associated mutex.

Parameters
__mThe associated mutex.

◆ shared_lock() [5/7]

template<typename Mutex >
template<typename _Clock , typename _Duration >
std::shared_lock< Mutex >::shared_lock ( mutex_type __m,
const chrono::time_point< _Clock, _Duration > &  __abs_time 
)
inline

Creates a shared_lock instance and tries to lock the associated mutex until the specified absolute time has passed.

Parameters
__mThe associated mutex.
__abs_timeThe absolute time.

◆ shared_lock() [6/7]

template<typename Mutex >
template<typename _Rep , typename _Period >
std::shared_lock< Mutex >::shared_lock ( mutex_type __m,
const chrono::duration< _Rep, _Period > &  __rel_time 
)
inline

Creates a shared_lock instance and tries to lock the associated mutex until the specified duration has passed.

Parameters
__mThe associated mutex.
__rel_timeThe time duration.

◆ shared_lock() [7/7]

template<typename Mutex >
std::shared_lock< Mutex >::shared_lock ( shared_lock< Mutex > &&  __sl)
inlinenoexcept

Creates a shared_lock instance based on the other shared lock.

Parameters
__slThe other shared_lock instance.

Member Function Documentation

◆ lock()

template<typename Mutex >
void std::shared_lock< Mutex >::lock ( )
inline

Takes ownership of the associated mutex.

◆ mutex()

template<typename Mutex >
mutex_type* std::shared_lock< Mutex >::mutex ( ) const
inlinenoexcept

Gets a pointer to the associated mutex.

Returns
The pointer to the associated mutex, or the null pointer if there is no associated mutex.

◆ operator bool()

template<typename Mutex >
std::shared_lock< Mutex >::operator bool ( ) const
inlineexplicitnoexcept

Checks whether the lock owns its associated mutex.

Returns
True if the lock has the associated mutex and owns it; false otherwise.

◆ operator=()

template<typename Mutex >
shared_lock& std::shared_lock< Mutex >::operator= ( shared_lock< Mutex > &&  __sl)
inlinenoexcept

The default move assignment operator.

Parameters
__slThe other shared_lock instance.

◆ owns_lock()

template<typename Mutex >
bool std::shared_lock< Mutex >::owns_lock ( ) const
inlinenoexcept

Checks whether the lock owns its associated mutex.

Returns
True if the lock has the associated mutex and owns it; false otherwise.

◆ release()

template<typename Mutex >
mutex_type* std::shared_lock< Mutex >::release ( )
inlinenoexcept

Disassociates the mutex without unlocking.

Returns
A pointer to the associated mutex or a null pointer if there is no associated mutex.

◆ swap()

template<typename Mutex >
void std::shared_lock< Mutex >::swap ( shared_lock< Mutex > &  __u)
inlinenoexcept

Exchanges the data members of two shared_lock instances.

Parameters
__uThe other shared_lock instance.

◆ try_lock()

template<typename Mutex >
bool std::shared_lock< Mutex >::try_lock ( )
inline

Tries to take ownership of the mutex without blocking.

Returns
True if the method takes ownership; false otherwise.

◆ try_lock_for()

template<typename Mutex >
template<typename _Rep , typename _Period >
bool std::shared_lock< Mutex >::try_lock_for ( const chrono::duration< _Rep, _Period > &  __rel_time)
inline

Tries to take shared ownership of the mutex and blocks it until the specified time elapses.

Parameters
__rel_timeThe time duration.
Returns
True if the method takes ownership; false otherwise.

◆ try_lock_until()

template<typename Mutex >
template<typename _Clock , typename _Duration >
bool std::shared_lock< Mutex >::try_lock_until ( const chrono::time_point< _Clock, _Duration > &  __abs_time)
inline

Tries to take shared ownership of the mutex and blocks it until the absolute time has passed.

Parameters
__abs_timeThe absolute time.
Returns
True if the method takes ownership; false otherwise.

◆ unlock()

template<typename Mutex >
void std::shared_lock< Mutex >::unlock ( )
inline

Releases the ownership of the mutex from the calling thread.


The documentation for this class was generated from the following file: