![]() |
Storage Engine API
|
Database lock with support for collection- and document-level locking. More...
#include <d_concurrency.h>
Database lock with support for collection- and document-level locking.
This lock supports four modes (see Lock_Mode): MODE_IS: concurrent database access, requiring further collection read locks MODE_IX: concurrent database access, requiring further collection read or write locks MODE_S: shared read access to the database, blocking any writers MODE_X: exclusive access to the database, blocking all other readers and writers
For MODE_IS or MODE_S also acquires global lock in intent-shared (IS) mode, and for MODE_IX or MODE_X also acquires global lock in intent-exclusive (IX) mode. For storage engines that do not support collection-level locking, MODE_IS will be upgraded to MODE_S and MODE_IX will be upgraded to MODE_X.
Public Member Functions | |
DBLock (OperationContext *opCtx, StringData db, LockMode mode, Date_t deadline=Date_t::max()) | |
DBLock (DBLock &&) | |
~DBLock () | |
void | relockWithMode (LockMode newMode) |
Releases the DBLock and reacquires it with the new mode. More... | |
bool | isLocked () const |
Private Attributes | |
const ResourceId | _id |
OperationContext *const | _opCtx |
LockResult | _result |
LockMode | _mode |
GlobalLock | _globalLock |
mongo::Lock::DBLock::DBLock | ( | OperationContext * | opCtx, |
StringData | db, | ||
LockMode | mode, | ||
Date_t | deadline = Date_t::max() |
||
) |
mongo::Lock::DBLock::DBLock | ( | DBLock && | otherLock | ) |
mongo::Lock::DBLock::~DBLock | ( | ) |
|
inline |
Releases the DBLock and reacquires it with the new mode.
The global intent lock is retained (so the database can't disappear). Relocking from MODE_IS or MODE_S to MODE_IX or MODE_X is not allowed to avoid violating the global intent. Use relockWithMode() instead of upgrading to avoid deadlock.
|
private |
|
private |
|
private |
|
private |
|
private |