XRootD
XrdCmsKeyItem Class Reference

#include <XrdCmsKey.hh>

+ Collaboration diagram for XrdCmsKeyItem:

Public Member Functions

 XrdCmsKeyItem ()
 
 ~XrdCmsKeyItem ()
 
void Recycle ()
 
void Reload ()
 

Static Public Member Functions

static XrdCmsKeyItemAlloc (unsigned int theTock)
 
static int Replenish ()
 
static void Stats (int &isAlloc, int &isFree, int &wasEmpty)
 
static XrdCmsKeyItemUnload (unsigned int theTock)
 
static XrdCmsKeyItemUnload (XrdCmsKeyItem *theItem)
 

Public Attributes

XrdCmsKey Key
 
XrdCmsKeyLoc Loc
 
XrdCmsKeyItemNext
 

Static Public Attributes

static const int minAlloc = 4096
 
static const int minFree = 1024
 
static const unsigned int TickMask = 63
 
static const unsigned int TickRate = 64
 

Detailed Description

Definition at line 125 of file XrdCmsKey.hh.

Constructor & Destructor Documentation

◆ XrdCmsKeyItem()

XrdCmsKeyItem::XrdCmsKeyItem ( )
inline

Definition at line 147 of file XrdCmsKey.hh.

147 {} // Warning see the constructor!

◆ ~XrdCmsKeyItem()

XrdCmsKeyItem::~XrdCmsKeyItem ( )
inline

Definition at line 148 of file XrdCmsKey.hh.

148 {} // These are usually never deleted

Member Function Documentation

◆ Alloc()

XrdCmsKeyItem * XrdCmsKeyItem::Alloc ( unsigned int  theTock)
static

Definition at line 71 of file XrdCmsKey.cc.

72 {
73  XrdCmsKeyItem *kP;
74 
75 // Try to allocate an existing item or replenish the list
76 //
77  do {if ((kP = Free))
78  {Free = kP->Next;
79  numFree--;
80  theTock &= TickMask;
81  kP->Key.TOD = theTock;
82  kP->Key.TODRef = TockTable[theTock];
83  TockTable[theTock] = kP;
84  if (!(kP->Key.Ref++)) kP->Key.Ref = 1;
85  kP->Loc.roPend = kP->Loc.rwPend = 0;
86  return kP;
87  }
88  numNull++;
89  } while(Replenish());
90 
91 // We failed
92 //
93  Say.Emsg("Key", ENOMEM, "create key item");
94  return (XrdCmsKeyItem *)0;
95 }
static const unsigned int TickMask
Definition: XrdCmsKey.hh:151
static int Replenish()
Definition: XrdCmsKey.cc:131
XrdCmsKeyLoc Loc
Definition: XrdCmsKey.hh:129
XrdCmsKey Key
Definition: XrdCmsKey.hh:130
XrdCmsKeyItem * Next
Definition: XrdCmsKey.hh:131
short rwPend
Definition: XrdCmsKey.hh:102
short roPend
Definition: XrdCmsKey.hh:101
XrdCmsKeyItem * TODRef
Definition: XrdCmsKey.hh:51
unsigned char TOD
Definition: XrdCmsKey.hh:55
unsigned char Ref
Definition: XrdCmsKey.hh:56
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdSysError Say

References XrdSysError::Emsg(), Key, Loc, Next, XrdCmsKey::Ref, XrdCmsKeyLoc::roPend, XrdCmsKeyLoc::rwPend, XrdCms::Say, XrdCmsKey::TOD, and XrdCmsKey::TODRef.

Referenced by XrdCmsNash::Add(), and XrdCmsCache::Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Recycle()

void XrdCmsKeyItem::Recycle ( )

Definition at line 101 of file XrdCmsKey.cc.

102 {
103  static char *noKey = (char *)"";
104 
105 // Clear up data areas
106 //
107  if (Key.Val && Key.Val != noKey) {free(Key.Val); Key.Val = noKey;}
108  Key.Ref++; Key.Hash = 0;
109 
110 // Put entry on the free list
111 //
112  Next = Free; Free = this;
113  numFree++;
114 }
unsigned int Hash
Definition: XrdCmsKey.hh:53
char * Val
Definition: XrdCmsKey.hh:52

Referenced by XrdCmsCache::DelFile(), XrdCmsCache::Init(), and XrdCmsNash::Recycle().

+ Here is the caller graph for this function:

◆ Reload()

void XrdCmsKeyItem::Reload ( )

Definition at line 120 of file XrdCmsKey.cc.

121 {
122  Key.TOD &= static_cast<unsigned char>(TickMask);
123  Key.TODRef = TockTable[Key.TOD];
124  TockTable[Key.TOD] = this;
125 }

◆ Replenish()

int XrdCmsKeyItem::Replenish ( )
static

Definition at line 131 of file XrdCmsKey.cc.

132 {
133  EPNAME("Replenish");
134  XrdCmsKeyItem *kP;
135  int i;
136 
137 // Allocate a quantum of free elements and chain them into the free list
138 //
139  if (!(kP = new XrdCmsKeyItem[minAlloc])) return 0;
140  DEBUG("old free " <<numFree <<" + " <<minAlloc <<" = " <<numHave+minAlloc);
141 
142 // We would do this in an initializer but that causes problems when alloacting
143 // temporary items on the stack. So, manually put these on the free list.
144 //
145  i = minAlloc;
146  while(i--) {kP->Next = Free; Free = kP; kP++;}
147 
148 // Return the number we have free
149 //
150  numHave += minAlloc;
151  numFree += minAlloc;
152  return numFree;
153 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
static const int minAlloc
Definition: XrdCmsKey.hh:152

References DEBUG, EPNAME, and Next.

◆ Stats()

void XrdCmsKeyItem::Stats ( int &  isAlloc,
int &  isFree,
int &  wasEmpty 
)
static

Definition at line 159 of file XrdCmsKey.cc.

160 {
161 
162  isAlloc = numHave;
163  isFree = numFree;
164  wasNull = numNull;
165  numNull = 0;
166 }

◆ Unload() [1/2]

XrdCmsKeyItem * XrdCmsKeyItem::Unload ( unsigned int  theTock)
static

Definition at line 172 of file XrdCmsKey.cc.

173 {
174  XrdCmsKeyItem myItem, *nP, *pP = &myItem;
175 
176 // Remove all entries from the indicated list. If any entries have been
177 // reassigned to a different list, move them to the right list. Otherwise,
178 // make the entry unfindable by clearing the hash code. Since item recycling
179 // requires knowing the hash code, we save it elsewhere in the object.
180 //
181  theTock &= TickMask;
182  myItem.Key.TODRef = TockTable[theTock]; TockTable[theTock] = 0;
183  while((nP = pP->Key.TODRef))
184  if (nP->Key.TOD == theTock)
185  {nP->Loc.HashSave = nP->Key.Hash; nP->Key.Hash = 0; pP = nP;}
186  else {pP->Key.TODRef = nP->Key.TODRef;
187  nP->Key.TODRef = TockTable[nP->Key.TOD];
188  TockTable[nP->Key.TOD] = nP;
189  }
190  return myItem.Key.TODRef;
191 }

References XrdCmsKey::Hash, Key, Loc, XrdCmsKey::TOD, and XrdCmsKey::TODRef.

Referenced by XrdCmsCache::DelFile(), XrdCmsCache::Init(), and XrdCmsCache::TickTock().

+ Here is the caller graph for this function:

◆ Unload() [2/2]

XrdCmsKeyItem * XrdCmsKeyItem::Unload ( XrdCmsKeyItem theItem)
static

Definition at line 195 of file XrdCmsKey.cc.

196 {
197  XrdCmsKeyItem *kP, *pP = 0;
198  unsigned int theTock = theItem->Key.TOD & TickMask;
199 
200 // Remove the entry from the right list
201 //
202  kP = TockTable[theTock];
203  while(kP && kP != theItem) {pP = kP; kP = kP->Key.TODRef;}
204  if (kP)
205  {if (pP) pP->Key.TODRef = kP->Key.TODRef;
206  else TockTable[theTock] = kP->Key.TODRef;
207  kP->Loc.HashSave = kP->Key.Hash; kP->Key.Hash = 0;
208  }
209  return kP;
210 }

References XrdCmsKey::Hash, Key, Loc, XrdCmsKey::TOD, and XrdCmsKey::TODRef.

Member Data Documentation

◆ Key

◆ Loc

◆ minAlloc

const int XrdCmsKeyItem::minAlloc = 4096
static

Definition at line 152 of file XrdCmsKey.hh.

◆ minFree

const int XrdCmsKeyItem::minFree = 1024
static

Definition at line 153 of file XrdCmsKey.hh.

◆ Next

XrdCmsKeyItem* XrdCmsKeyItem::Next

◆ TickMask

const unsigned int XrdCmsKeyItem::TickMask = 63
static

Definition at line 151 of file XrdCmsKey.hh.

Referenced by XrdCmsCache::TickTock().

◆ TickRate

const unsigned int XrdCmsKeyItem::TickRate = 64
static

Definition at line 150 of file XrdCmsKey.hh.

Referenced by XrdCmsCache::Init().


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