LockHolderId Class Reference

LockHolderId encapsulates the identity of an entity which can hold a lock, currently either a transaction or a thread. More...

#include <LockHolderId.h>

List of all members.

Public Member Functions

 LockHolderId ()
 Creates a new null holder.
 LockHolderId (TxnId txnId)
 Creates a new ID corresponding to a transaction or thread ID.
void assignFrom (TxnId txnId)
 Assigns identity from a transaction or thread ID.
bool isNull () const
 
Returns:
whether this holder is null (has not been assigned an identity)

void setNull ()
 Sets this holder to null.
int operator== (LockHolderId const &other) const
 Compares this holder to another.

Private Types

enum  HolderType { TYPE_NULL, TYPE_THREAD, TYPE_TXN }

Private Attributes

TxnId holderId
HolderType holderType


Detailed Description

LockHolderId encapsulates the identity of an entity which can hold a lock, currently either a transaction or a thread.

Author:
John V. Sichi
Version:
Id
//open/dev/fennel/synch/LockHolderId.h#5

Definition at line 35 of file LockHolderId.h.


Member Enumeration Documentation

enum LockHolderId::HolderType [private]

Enumerator:
TYPE_NULL 
TYPE_THREAD 
TYPE_TXN 

Definition at line 37 of file LockHolderId.h.

00037                     {
00038         TYPE_NULL,
00039         TYPE_THREAD,
00040         TYPE_TXN
00041     };


Constructor & Destructor Documentation

LockHolderId::LockHolderId (  )  [inline, explicit]

Creates a new null holder.

Definition at line 108 of file LockHolderId.h.

References setNull().

00109 {
00110     setNull();
00111 }

LockHolderId::LockHolderId ( TxnId  txnId  )  [inline, explicit]

Creates a new ID corresponding to a transaction or thread ID.

Parameters:
txnId ID of a transaction, or IMPLICIT_TXN_ID to assign from the current thread ID

Definition at line 113 of file LockHolderId.h.

References assignFrom().

00114 {
00115     assignFrom(txnId);
00116 }


Member Function Documentation

void LockHolderId::assignFrom ( TxnId  txnId  )  [inline]

Assigns identity from a transaction or thread ID.

Parameters:
txnId ID of a transaction, or IMPLICIT_TXN_ID to assign from the current thread ID

Definition at line 89 of file LockHolderId.h.

References getCurrentThreadId(), holderId, holderType, IMPLICIT_TXN_ID, TYPE_THREAD, and TYPE_TXN.

Referenced by LockHolderId().

00090 {
00091     if (txnId == IMPLICIT_TXN_ID) {
00092         // NOTE jvs 2-Jun-2007:  Not exactly posixly correct,
00093         // but it will probably do for most environments.
00094         holderId = TxnId(uint(getCurrentThreadId()));
00095         holderType = TYPE_THREAD;
00096     } else {
00097         holderId = txnId;
00098         holderType = TYPE_TXN;
00099     }
00100 }

bool LockHolderId::isNull (  )  const [inline]

Returns:
whether this holder is null (has not been assigned an identity)

Definition at line 118 of file LockHolderId.h.

References holderType, and TYPE_NULL.

Referenced by SXMutex::tryUpgrade(), and SXMutex::~SXMutex().

00119 {
00120     return holderType == TYPE_NULL;
00121 }

void LockHolderId::setNull (  )  [inline]

Sets this holder to null.

Definition at line 102 of file LockHolderId.h.

References holderId, holderType, NULL_TXN_ID, and TYPE_NULL.

Referenced by LockHolderId(), and SXMutex::release().

00103 {
00104     holderId = NULL_TXN_ID;
00105     holderType = TYPE_NULL;
00106 }

int LockHolderId::operator== ( LockHolderId const &  other  )  const [inline]

Compares this holder to another.

Parameters:
other other holder to compare
Returns:
whether the two holders identify the same entity (or are both null)

Definition at line 123 of file LockHolderId.h.

References holderId, and holderType.

00124 {
00125     return (holderId == other.holderId)
00126         && (holderType == other.holderType);
00127 }


Member Data Documentation

TxnId LockHolderId::holderId [private]

Definition at line 43 of file LockHolderId.h.

Referenced by assignFrom(), operator==(), and setNull().

HolderType LockHolderId::holderType [private]

Definition at line 44 of file LockHolderId.h.

Referenced by assignFrom(), isNull(), operator==(), and setNull().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:39 2009 for Fennel by  doxygen 1.5.1