00001 #ifndef __XRDCMSKEY_HH__
00002 #define __XRDCMSKEY_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <string.h>
00016
00017 #include "XrdCms/XrdCmsTypes.hh"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class XrdCmsKeyItem;
00028
00029 class XrdCmsKey
00030 {
00031 public:
00032
00033 XrdCmsKeyItem *TODRef;
00034 char *Val;
00035 unsigned int Hash;
00036 short Len;
00037 unsigned char TOD;
00038 unsigned char Ref;
00039
00040 void setHash();
00041
00042 inline int Equiv(XrdCmsKey &oth)
00043 {return Hash == oth.Hash && Ref == oth.Ref;}
00044
00045 inline XrdCmsKey& operator=(const XrdCmsKey &rhs)
00046 {Val = strdup(rhs.Val); Hash = rhs.Hash;
00047 Len = rhs.Len;
00048 return *this;
00049 }
00050
00051 inline int operator==(const XrdCmsKey &oth)
00052 {return Hash == oth.Hash && !strcmp(Val, oth.Val);}
00053
00054 inline int operator!=(const XrdCmsKey &oth)
00055 {return Hash != oth.Hash || strcmp(Val, oth.Val);}
00056
00057 XrdCmsKey(char *key=0, int klen=0)
00058 : TODRef(0), Val(key), Hash(0), Len(klen), Ref('\0') {}
00059 ~XrdCmsKey() {};
00060 };
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 class XrdCmsKeyLoc
00071 {
00072 public:
00073
00074 SMask_t hfvec;
00075 SMask_t pfvec;
00076 SMask_t qfvec;
00077 unsigned int TOD_B;
00078 unsigned int Reserved;
00079 union {
00080 unsigned int HashSave;
00081 int deadline;
00082 };
00083 short roPend;
00084 short rwPend;
00085
00086 inline
00087 XrdCmsKeyLoc& operator=(const XrdCmsKeyLoc &rhs)
00088 {hfvec=rhs.hfvec; pfvec=rhs.pfvec; TOD_B=rhs.TOD_B;
00089 deadline = rhs.deadline;
00090 roPend = rhs.roPend; rwPend = rhs.rwPend;
00091 return *this;
00092 }
00093
00094 XrdCmsKeyLoc() : roPend(0), rwPend(0) {}
00095 ~XrdCmsKeyLoc() {}
00096 };
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 class XrdCmsKeyItem
00107 {
00108 public:
00109
00110 XrdCmsKeyLoc Loc;
00111 XrdCmsKey Key;
00112 XrdCmsKeyItem *Next;
00113
00114 static XrdCmsKeyItem *Alloc(unsigned int theTock);
00115
00116 void Recycle();
00117
00118 void Reload();
00119
00120 static int Replenish();
00121
00122 static void Stats(int &isAlloc, int &isFree, int &wasEmpty);
00123
00124 static XrdCmsKeyItem *Unload(unsigned int theTock);
00125
00126 static XrdCmsKeyItem *Unload(XrdCmsKeyItem *theItem);
00127
00128 XrdCmsKeyItem() {}
00129 ~XrdCmsKeyItem() {}
00130
00131 static const unsigned int TickRate = 64;
00132 static const unsigned int TickMask = 63;
00133 static const int minAlloc = 4096;
00134 static const int minFree = 1024;
00135
00136 private:
00137
00138 static XrdCmsKeyItem *TockTable[TickRate];
00139 static XrdCmsKeyItem *Free;
00140 static int numFree;
00141 static int numHave;
00142 static int numNull;
00143 };
00144 #endif