Storage Engine API
mongo::LockerForTests Class Reference

#include <lock_manager_test_help.h>

Inheritance diagram for mongo::LockerForTests:
mongo::LockerImpl< false > mongo::Locker

Public Member Functions

 LockerForTests (LockMode globalLockMode)
 
 ~LockerForTests ()
 
- Public Member Functions inherited from mongo::LockerImpl< false >
 LockerImpl ()
 Instantiates new locker. More...
 
virtual ~LockerImpl ()
 
virtual ClientState getClientState () const
 Return whether client is holding any locks (active), or is queued on any locks or waiting for a ticket (throttled). More...
 
virtual LockerId getId () const
 
stdx::thread::id getThreadId () const override
 Get a platform-specific thread identifier of the thread which owns the this locker for tracing purposes. More...
 
void updateThreadIdToCurrentThread () override
 Updates any cached thread id values to represent the current thread. More...
 
void unsetThreadId () override
 Clears any cached thread id values. More...
 
void setSharedLocksShouldTwoPhaseLock (bool sharedLocksShouldTwoPhaseLock) override
 Indicate that shared locks should participate in two-phase locking for this Locker instance. More...
 
void setMaxLockTimeout (Milliseconds maxTimeout) override
 This is useful to ensure that potential deadlocks do not occur. More...
 
bool hasMaxLockTimeout () override
 Returns whether this Locker has a maximum lock timeout set. More...
 
void unsetMaxLockTimeout () override
 Clears the max lock timeout override set by setMaxLockTimeout() above. More...
 
virtual LockResult lockGlobal (OperationContext *opCtx, LockMode mode)
 This should be the first method invoked for a particular Locker object. More...
 
virtual LockResult lockGlobal (LockMode mode)
 
virtual LockResult lockGlobalBegin (OperationContext *opCtx, LockMode mode, Date_t deadline)
 Requests the global lock to be acquired in the specified mode. More...
 
virtual LockResult lockGlobalBegin (LockMode mode, Date_t deadline)
 
virtual LockResult lockGlobalComplete (OperationContext *opCtx, Date_t deadline)
 Calling lockGlobalComplete without an OperationContext does not allow the lock acquisition to be interrupted. More...
 
virtual LockResult lockGlobalComplete (Date_t deadline)
 
virtual void lockMMAPV1Flush ()
 This method is used only in the MMAP V1 storage engine, otherwise it is a no-op. More...
 
virtual void downgradeGlobalXtoSForMMAPV1 ()
 This is only necessary for the MMAP V1 engine and in particular, the fsyncLock command which needs to first acquire the global lock in X-mode for truncating the journal and then downgrade to S before it blocks. More...
 
virtual bool unlockGlobal ()
 Decrements the reference count on the global lock. More...
 
virtual void beginWriteUnitOfWork ()
 beginWriteUnitOfWork/endWriteUnitOfWork are called at the start and end of WriteUnitOfWorks. More...
 
virtual void endWriteUnitOfWork ()
 
virtual bool inAWriteUnitOfWork () const
 
virtual LockResult lock (OperationContext *opCtx, ResourceId resId, LockMode mode, Date_t deadline=Date_t::max(), bool checkDeadlock=false)
 Requests a lock for resource 'resId' with mode 'mode'. More...
 
virtual LockResult lock (ResourceId resId, LockMode mode, Date_t deadline=Date_t::max(), bool checkDeadlock=false)
 Calling lock without an OperationContext does not allow LOCK_WAITING states to be interrupted. More...
 
virtual void downgrade (ResourceId resId, LockMode newMode)
 Downgrades the specified resource's lock mode without changing the reference count. More...
 
virtual bool unlock (ResourceId resId)
 Releases a lock previously acquired through a lock call. More...
 
virtual LockMode getLockMode (ResourceId resId) const
 Retrieves the mode in which a lock is held or checks whether the lock held for a particular resource covers the specified mode. More...
 
virtual bool isLockHeldForMode (ResourceId resId, LockMode mode) const
 
virtual bool isDbLockedForMode (StringData dbName, LockMode mode) const
 
virtual bool isCollectionLockedForMode (StringData ns, LockMode mode) const
 
virtual ResourceId getWaitingResource () const
 Returns the resource that this locker is waiting/blocked on (if any). More...
 
virtual void getLockerInfo (LockerInfo *lockerInfo) const
 
virtual boost::optional< LockerInfogetLockerInfo () const final
 Returns boost::none if this is an instance of LockerNoop, or a populated LockerInfo otherwise. More...
 
virtual bool saveLockStateAndUnlock (LockSnapshot *stateOut)
 Retrieves all locks held by this transaction, other than RESOURCE_MUTEX locks, and what mode they're held in. More...
 
virtual void restoreLockState (OperationContext *opCtx, const LockSnapshot &stateToRestore)
 Re-locks all locks whose state was stored in 'stateToRestore'. More...
 
virtual void restoreLockState (const LockSnapshot &stateToRestore)
 
virtual void releaseTicket ()
 Releases the ticket associated with the Locker. More...
 
virtual void reacquireTicket (OperationContext *opCtx)
 Reacquires a ticket for the Locker. More...
 
LockResult lockBegin (OperationContext *opCtx, ResourceId resId, LockMode mode)
 Allows for lock requests to be requested in a non-blocking way. More...
 
LockResult lockComplete (OperationContext *opCtx, ResourceId resId, LockMode mode, Date_t deadline, bool checkDeadlock)
 Waits for the completion of a lock, previously requested through lockBegin or lockGlobalBegin. More...
 
LockResult lockComplete (ResourceId resId, LockMode mode, Date_t deadline, bool checkDeadlock)
 
FastMapNoAlloc< ResourceId, LockRequestgetRequestsForTest () const
 This function is for unit testing only. More...
 
virtual void dump () const
 
virtual bool isW () const
 
virtual bool isR () const
 
virtual bool isLocked () const
 
virtual bool isWriteLocked () const
 
virtual bool isReadLocked () const
 
bool isGlobalLockedRecursively () override
 
virtual bool hasLockPending () const
 Pending means we are currently trying to get a lock (could be the parallel batch writer lock). More...
 
- Public Member Functions inherited from mongo::Locker
virtual ~Locker ()
 
virtual bool isNoop () const
 Returns true if this is an instance of LockerNoop. More...
 
void setShouldConflictWithSecondaryBatchApplication (bool newValue)
 If set to false, this opts out of conflicting with replication's use of the ParallelBatchWriterMode lock. More...
 
bool shouldConflictWithSecondaryBatchApplication () const
 
void setShouldAcquireTicket (bool newValue)
 If set to false, this opts out of the ticket mechanism. More...
 
bool shouldAcquireTicket () const
 
unsigned numResourcesToUnlockAtEndUnitOfWorkForTest () const
 This function is for unit testing only. More...
 

Additional Inherited Members

- Public Types inherited from mongo::Locker
enum  ClientState {
  kInactive, kActiveReader, kActiveWriter, kQueuedReader,
  kQueuedWriter
}
 State for reporting the number of active and queued reader and writer clients. More...
 
- Static Public Member Functions inherited from mongo::Locker
static void setGlobalThrottling (class TicketHolder *reading, class TicketHolder *writing)
 Require global lock attempts to obtain tickets from 'reading' (for MODE_S and MODE_IS), and from 'writing' (for MODE_IX), which must have static lifetimes. More...
 
- Protected Member Functions inherited from mongo::Locker
 Locker ()
 
- Protected Attributes inherited from mongo::Locker
int _uninterruptibleLocksRequested = 0
 The number of callers that are guarding from lock interruptions. More...
 
unsigned _numResourcesToUnlockAtEndUnitOfWork = 0
 The number of LockRequests to unlock at the end of this WUOW. More...
 

Constructor & Destructor Documentation

◆ LockerForTests()

mongo::LockerForTests::LockerForTests ( LockMode  globalLockMode)
inlineexplicit

◆ ~LockerForTests()

mongo::LockerForTests::~LockerForTests ( )
inline

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