Storage Engine API
mongo::ResourceId Class Reference

Uniquely identifies a lockable resource. More...

#include <lock_manager_defs.h>

Detailed Description

Uniquely identifies a lockable resource.

Public Types

enum  SingletonHashIds { SINGLETON_INVALID = 0, SINGLETON_PARALLEL_BATCH_WRITER_MODE, SINGLETON_GLOBAL, SINGLETON_MMAPV1_FLUSH }
 Assign hash ids for special resources to avoid accidental reuse of ids. More...
 

Public Member Functions

 ResourceId ()
 
 ResourceId (ResourceType type, StringData ns)
 
 ResourceId (ResourceType type, const std::string &ns)
 
 ResourceId (ResourceType type, uint64_t hashId)
 
bool isValid () const
 
 operator uint64_t () const
 
bool operator< (const ResourceId &rhs) const
 
ResourceType getType () const
 
uint64_t getHashId () const
 
std::string toString () const
 

Private Types

enum  { resourceTypeBits = 3 }
 

Private Member Functions

 MONGO_STATIC_ASSERT (ResourceTypesCount<=(1<< resourceTypeBits))
 

Static Private Member Functions

static uint64_t fullHash (ResourceType type, uint64_t hashId)
 

Private Attributes

uint64_t _fullHash
 The top 'resourceTypeBits' bits of '_fullHash' represent the resource type, while the remaining bits contain the bottom bits of the hashId. More...
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
resourceTypeBits 

◆ SingletonHashIds

Assign hash ids for special resources to avoid accidental reuse of ids.

For ids used with the same ResourceType, the order here must be the same as the locking order.

Enumerator
SINGLETON_INVALID 
SINGLETON_PARALLEL_BATCH_WRITER_MODE 
SINGLETON_GLOBAL 
SINGLETON_MMAPV1_FLUSH 

Constructor & Destructor Documentation

◆ ResourceId() [1/4]

mongo::ResourceId::ResourceId ( )
inline

◆ ResourceId() [2/4]

mongo::ResourceId::ResourceId ( ResourceType  type,
StringData  ns 
)

◆ ResourceId() [3/4]

mongo::ResourceId::ResourceId ( ResourceType  type,
const std::string &  ns 
)

◆ ResourceId() [4/4]

mongo::ResourceId::ResourceId ( ResourceType  type,
uint64_t  hashId 
)

Member Function Documentation

◆ fullHash()

uint64_t mongo::ResourceId::fullHash ( ResourceType  type,
uint64_t  hashId 
)
staticprivate

◆ getHashId()

uint64_t mongo::ResourceId::getHashId ( ) const
inline

◆ getType()

ResourceType mongo::ResourceId::getType ( ) const
inline

◆ isValid()

bool mongo::ResourceId::isValid ( ) const
inline

◆ MONGO_STATIC_ASSERT()

mongo::ResourceId::MONGO_STATIC_ASSERT ( ResourceTypesCount<=  1<< resourceTypeBits)
private

◆ operator uint64_t()

mongo::ResourceId::operator uint64_t ( ) const
inline

◆ operator<()

bool mongo::ResourceId::operator< ( const ResourceId rhs) const
inline

◆ toString()

std::string mongo::ResourceId::toString ( ) const

Member Data Documentation

◆ _fullHash

uint64_t mongo::ResourceId::_fullHash
private

The top 'resourceTypeBits' bits of '_fullHash' represent the resource type, while the remaining bits contain the bottom bits of the hashId.

This avoids false conflicts between resources of different types, which is necessary to prevent deadlocks.


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