![]() |
Storage Engine API
|
Uniquely identifies a lockable resource. More...
#include <lock_manager_defs.h>
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... | |
|
inline |
mongo::ResourceId::ResourceId | ( | ResourceType | type, |
StringData | ns | ||
) |
mongo::ResourceId::ResourceId | ( | ResourceType | type, |
const std::string & | ns | ||
) |
mongo::ResourceId::ResourceId | ( | ResourceType | type, |
uint64_t | hashId | ||
) |
|
staticprivate |
|
inline |
|
inline |
|
inline |
|
private |
|
inline |
|
inline |
std::string mongo::ResourceId::toString | ( | ) | const |
|
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.