Storage Engine API
mongo::Lock::GlobalLock Class Reference

Global lock. More...

#include <d_concurrency.h>

Inheritance diagram for mongo::Lock::GlobalLock:
mongo::Lock::GlobalRead mongo::Lock::GlobalWrite

Detailed Description

Global lock.

Grabs global resource lock. Allows further (recursive) acquisition of the global lock in any mode, see LockMode. An outermost GlobalLock, when not in a WriteUnitOfWork, calls abandonSnapshot() on destruction. This allows the storage engine to release resources, such as snapshots or locks, that it may have acquired during the transaction.

NOTE: Does not acquire flush lock.

Classes

class  EnqueueOnly
 

Public Member Functions

 GlobalLock (OperationContext *opCtx, LockMode lockMode)
 A GlobalLock without a deadline defaults to Date_t::max() and an InterruptBehavior of kThrow. More...
 
 GlobalLock (OperationContext *opCtx, LockMode lockMode, Date_t deadline, InterruptBehavior behavior)
 A GlobalLock with a deadline requires the interrupt behavior to be explicitly defined. More...
 
 GlobalLock (GlobalLock &&)
 
 GlobalLock (OperationContext *opCtx, LockMode lockMode, Date_t deadline, InterruptBehavior behavior, EnqueueOnly enqueueOnly)
 Enqueues lock but does not block on lock acquisition. More...
 
 ~GlobalLock ()
 
void waitForLockUntil (Date_t deadline)
 Waits for lock to be granted. More...
 
bool isLocked () const
 

Private Member Functions

void _enqueue (LockMode lockMode, Date_t deadline)
 
void _unlock ()
 

Private Attributes

OperationContext *const _opCtx
 
LockResult _result
 
ResourceLock _pbwm
 
InterruptBehavior _interruptBehavior
 
const bool _isOutermostLock
 

Constructor & Destructor Documentation

◆ GlobalLock() [1/4]

mongo::Lock::GlobalLock::GlobalLock ( OperationContext *  opCtx,
LockMode  lockMode 
)
inline

A GlobalLock without a deadline defaults to Date_t::max() and an InterruptBehavior of kThrow.

◆ GlobalLock() [2/4]

mongo::Lock::GlobalLock::GlobalLock ( OperationContext *  opCtx,
LockMode  lockMode,
Date_t  deadline,
InterruptBehavior  behavior 
)

A GlobalLock with a deadline requires the interrupt behavior to be explicitly defined.

◆ GlobalLock() [3/4]

mongo::Lock::GlobalLock::GlobalLock ( GlobalLock &&  otherLock)

◆ GlobalLock() [4/4]

mongo::Lock::GlobalLock::GlobalLock ( OperationContext *  opCtx,
LockMode  lockMode,
Date_t  deadline,
InterruptBehavior  behavior,
EnqueueOnly  enqueueOnly 
)

Enqueues lock but does not block on lock acquisition.

Call waitForLockUntil() to complete locking process.

Does not set that the global lock was taken on the GlobalLockAcquisitionTracker. Call waitForLockUntil to do so.

◆ ~GlobalLock()

mongo::Lock::GlobalLock::~GlobalLock ( )
inline

Member Function Documentation

◆ _enqueue()

void mongo::Lock::GlobalLock::_enqueue ( LockMode  lockMode,
Date_t  deadline 
)
private

◆ _unlock()

void mongo::Lock::GlobalLock::_unlock ( )
private

◆ isLocked()

bool mongo::Lock::GlobalLock::isLocked ( ) const
inline

◆ waitForLockUntil()

void mongo::Lock::GlobalLock::waitForLockUntil ( Date_t  deadline)

Waits for lock to be granted.

Sets that the global lock was taken on the GlobalLockAcquisitionTracker.

Member Data Documentation

◆ _interruptBehavior

InterruptBehavior mongo::Lock::GlobalLock::_interruptBehavior
private

◆ _isOutermostLock

const bool mongo::Lock::GlobalLock::_isOutermostLock
private

◆ _opCtx

OperationContext* const mongo::Lock::GlobalLock::_opCtx
private

◆ _pbwm

ResourceLock mongo::Lock::GlobalLock::_pbwm
private

◆ _result

LockResult mongo::Lock::GlobalLock::_result
private

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