OmniSciDB  2e3a973ef4
lockmgr::MutexTracker Class Reference

#include <LockMgrImpl.h>

Public Member Functions

 MutexTracker ()
 
MutexTypeBaseacquire ()
 
void release ()
 
bool isAcquired () const
 

Private Attributes

std::atomic< size_t > ref_count_
 
MutexTypeBase mutex_
 

Detailed Description

Definition at line 36 of file LockMgrImpl.h.

Constructor & Destructor Documentation

◆ MutexTracker()

lockmgr::MutexTracker::MutexTracker ( )
inline

Definition at line 38 of file LockMgrImpl.h.

38 : ref_count_(0u) {}
std::atomic< size_t > ref_count_
Definition: LockMgrImpl.h:53

Member Function Documentation

◆ acquire()

MutexTypeBase& lockmgr::MutexTracker::acquire ( )
inline

Definition at line 40 of file LockMgrImpl.h.

References mutex_, and ref_count_.

40  {
41  ref_count_.fetch_add(1u);
42  return mutex_;
43  }
MutexTypeBase mutex_
Definition: LockMgrImpl.h:54
std::atomic< size_t > ref_count_
Definition: LockMgrImpl.h:53

◆ isAcquired()

bool lockmgr::MutexTracker::isAcquired ( ) const
inline

Definition at line 50 of file LockMgrImpl.h.

References ref_count_.

50 { return ref_count_.load() > 0; }
std::atomic< size_t > ref_count_
Definition: LockMgrImpl.h:53

◆ release()

void lockmgr::MutexTracker::release ( )
inline

Definition at line 45 of file LockMgrImpl.h.

References CHECK_GE, and ref_count_.

45  {
46  const auto stored_ref_count = ref_count_.fetch_sub(1u);
47  CHECK_GE(stored_ref_count, size_t(1));
48  }
#define CHECK_GE(x, y)
Definition: Logger.h:210
std::atomic< size_t > ref_count_
Definition: LockMgrImpl.h:53

Member Data Documentation

◆ mutex_

MutexTypeBase lockmgr::MutexTracker::mutex_
private

◆ ref_count_

std::atomic<size_t> lockmgr::MutexTracker::ref_count_
private

Definition at line 53 of file LockMgrImpl.h.

Referenced by acquire(), isAcquired(), and release().


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