XRootD
XrdCmsNash Class Reference

#include <XrdCmsNash.hh>

+ Collaboration diagram for XrdCmsNash:

Public Member Functions

 XrdCmsNash (int psize=17711, int size=28657)
 
 ~XrdCmsNash ()
 
XrdCmsKeyItemAdd (XrdCmsKey &Key)
 
XrdCmsKeyItemFind (XrdCmsKey &Key)
 
int Recycle (XrdCmsKeyItem *rip)
 

Detailed Description

Definition at line 35 of file XrdCmsNash.hh.

Constructor & Destructor Documentation

◆ XrdCmsNash()

XrdCmsNash::XrdCmsNash ( int  psize = 17711,
int  size = 28657 
)

Definition at line 39 of file XrdCmsNash.cc.

40 {
41  prevtablesize = psize;
42  nashtablesize = csize;
43  Threshold = (csize * LoadMax) / 100;
44  nashnum = 0;
45  nashtable = (XrdCmsKeyItem **)
46  malloc( (size_t)(csize*sizeof(XrdCmsKeyItem *)) );
47  memset((void *)nashtable, 0, (size_t)(csize*sizeof(XrdCmsKeyItem *)));
48 }

◆ ~XrdCmsNash()

XrdCmsNash::~XrdCmsNash ( )
inline

Definition at line 49 of file XrdCmsNash.hh.

49 {} // Never gets deleted

Member Function Documentation

◆ Add()

XrdCmsKeyItem * XrdCmsNash::Add ( XrdCmsKey Key)

Definition at line 54 of file XrdCmsNash.cc.

55 {
56  XrdCmsKeyItem *hip;
57  unsigned int kent;
58 
59 // Allocate the entry
60 //
61  if (!(hip = XrdCmsKeyItem::Alloc(Key.TOD))) return (XrdCmsKeyItem *)0;
62 
63 // Check if we should expand the table
64 //
65  if (++nashnum > Threshold) Expand();
66 
67 // Fill out the key data
68 //
69  if (!Key.Hash) Key.setHash();
70  hip->Key = Key;
71 
72 // Add the entry to the table
73 //
74  kent = Key.Hash % nashtablesize;
75  hip->Next = nashtable[kent];
76  nashtable[kent] = hip;
77  return hip;
78 }
static XrdCmsKeyItem * Alloc(unsigned int theTock)
Definition: XrdCmsKey.cc:71
XrdCmsKey Key
Definition: XrdCmsKey.hh:130
XrdCmsKeyItem * Next
Definition: XrdCmsKey.hh:131
void setHash()
Definition: XrdCmsKey.cc:48
unsigned int Hash
Definition: XrdCmsKey.hh:53
unsigned char TOD
Definition: XrdCmsKey.hh:55

References XrdCmsKeyItem::Alloc(), XrdCmsKey::Hash, XrdCmsKeyItem::Key, XrdCmsKeyItem::Next, XrdCmsKey::setHash(), and XrdCmsKey::TOD.

+ Here is the call graph for this function:

◆ Find()

XrdCmsKeyItem * XrdCmsNash::Find ( XrdCmsKey Key)

Definition at line 129 of file XrdCmsNash.cc.

130 {
131  XrdCmsKeyItem *nip;
132  unsigned int kent;
133 
134 // Check if we already have a hash value and get one if not
135 //
136  if (!Key.Hash) Key.setHash();
137 
138 // Compute position of the hash table entry
139 //
140  kent = Key.Hash%nashtablesize;
141 
142 // Find the entry
143 //
144  nip = nashtable[kent];
145  while(nip && nip->Key != Key) nip = nip->Next;
146  return nip;
147 }

References XrdCmsKey::Hash, XrdCmsKeyItem::Key, XrdCmsKeyItem::Next, and XrdCmsKey::setHash().

+ Here is the call graph for this function:

◆ Recycle()

int XrdCmsNash::Recycle ( XrdCmsKeyItem rip)

Definition at line 156 of file XrdCmsNash.cc.

157 {
158  XrdCmsKeyItem *nip, *pip = 0;
159  unsigned int kent;
160 
161 // Compute position of the hash table entry
162 //
163  kent = rip->Loc.HashSave%nashtablesize;
164 
165 // Find the entry
166 //
167  nip = nashtable[kent];
168  while(nip && nip != rip) {pip = nip; nip = nip->Next;}
169 
170 // Remove and recycle if found
171 //
172  if (nip)
173  {if (pip) pip->Next = nip->Next;
174  else nashtable[kent] = nip->Next;
175  rip->Recycle();
176  nashnum--;
177  }
178  return nip != 0;
179 }
void Recycle()
Definition: XrdCmsKey.cc:101
XrdCmsKeyLoc Loc
Definition: XrdCmsKey.hh:129

References XrdCmsKeyItem::Loc, XrdCmsKeyItem::Next, and XrdCmsKeyItem::Recycle().

+ Here is the call graph for this function:

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