XRootD
Loading...
Searching...
No Matches
XrdOucRash< K, V > Class Template Reference

#include <XrdOucRash.hh>

+ Collaboration diagram for XrdOucRash< K, V >:

Public Member Functions

 XrdOucRash ()
 
 ~XrdOucRash ()
 
V * Add (K KeyVal, V &KeyData, time_t LifeTime=0, XrdOucRash_Options opt=Rash_default)
 
V * Apply (int(*func)(K, V, void *), void *Arg)
 
int Del (K KeyVal)
 
V * Find (K KeyVal, time_t *KeyTime=0)
 
int Num ()
 
void Purge ()
 
V * Rep (K KeyVal, V &KeyData, const int LifeTime=0, XrdOucRash_Options opt=Rash_default)
 

Detailed Description

template<typename K, typename V>
class XrdOucRash< K, V >

Definition at line 112 of file XrdOucRash.hh.

Constructor & Destructor Documentation

◆ XrdOucRash()

template<typename K, typename V>
XrdOucRash< K, V >::XrdOucRash ( )
inline

Definition at line 166 of file XrdOucRash.hh.

166{rashnum = 0;}

◆ ~XrdOucRash()

template<typename K, typename V>
XrdOucRash< K, V >::~XrdOucRash ( )
inline

Definition at line 167 of file XrdOucRash.hh.

167{Purge();}

References Purge().

+ Here is the call graph for this function:

Member Function Documentation

◆ Add()

template<typename K, typename V>
V * XrdOucRash< K, V >::Add ( K KeyVal,
V & KeyData,
time_t LifeTime = 0,
XrdOucRash_Options opt = Rash_default )

Definition at line 39 of file XrdOucRash.icc.

41{
45
46// Look up the entry. If found, either return an error or delete it
47// because caller wanted it replaced or it has expired.
48//
49 if ((hip = Lookup(KeyVal, &hiploc)))
50 {if (opt & Rash_count)
51 {hip->Update(hip->Count()+1,
52 (LifeTime || hip->Time() ? LifeTime + time(0) : 0) );}
53 if (!(opt & Rash_replace)
54 && ((lifetime=hip->Time())==0||lifetime>=time(0))) return hip->Data();
55 hip->Set(KeyData, KeyTime);
56 return (V *)0;
57 }
58
59// Create a new item
60//
61 if (LifeTime) KeyTime = LifeTime + time(0);
63 throw ENOMEM;
64
65// Add this item to the table
66//
67 Insert(KeyVal, hip);
68 return (V *)0;
69}

References XrdOucRash_Item< K, V >::Count(), XrdOucRash_Item< K, V >::Data(), Rash_count, Rash_replace, XrdOucRash_Item< K, V >::Set(), XrdOucRash_Item< K, V >::Time(), and XrdOucRash_Item< K, V >::Update().

Referenced by Rep().

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

◆ Apply()

template<typename K, typename V>
V * XrdOucRash< K, V >::Apply ( int(* func )(K, V, void *),
void * Arg )
inline

Definition at line 163 of file XrdOucRash.hh.

164 {return Apply(rashTable, func, Arg);}
V * Apply(int(*func)(K, V, void *), void *Arg)

References Apply().

Referenced by Apply().

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

◆ Del()

template<typename K, typename V>
int XrdOucRash< K, V >::Del ( K KeyVal)

Definition at line 76 of file XrdOucRash.icc.

77{
80 int cnt;
81
82// Look up the entry. If not found, indicate so.
83//
84 if (!(hip = Lookup(KeyVal, &hiploc))) return -ENOENT;
85
86// Delete the item and return
87//
88 if ((cnt = hip->Count())) {hip->Update(cnt-1, 0); return cnt;}
89 delete hip;
90 hiploc->Item = (XrdOucRash_Item<K,V> *)0;
91 rashnum--;
92 return 0;
93
94}

References XrdOucRash_Item< K, V >::Count(), XrdOucRash_Tent< K, V >::Item, and XrdOucRash_Item< K, V >::Update().

+ Here is the call graph for this function:

◆ Find()

template<typename K, typename V>
V * XrdOucRash< K, V >::Find ( K KeyVal,
time_t * KeyTime = 0 )

Definition at line 101 of file XrdOucRash.icc.

102{
105 time_t lifetime = 0;
106
107// Find the entry (remove it if expired and return nothing)
108//
109 if (!(hip = Lookup(KeyVal, &hiploc))) return (V *)0;
110 if ( (lifetime = hip->Time()) && lifetime < time(0) )
111 {delete hip;
112 hiploc->Item = (XrdOucRash_Item<K,V> *)0;
113 rashnum--;
114 if (KeyTime) *KeyTime = (time_t)0;
115 return (V *)0;
116 }
117
118// Return actual information
119//
120 if (KeyTime) *KeyTime = lifetime;
121 return hip->Data();
122}

References XrdOucRash_Item< K, V >::Data(), XrdOucRash_Tent< K, V >::Item, and XrdOucRash_Item< K, V >::Time().

+ Here is the call graph for this function:

◆ Num()

template<typename K, typename V>
int XrdOucRash< K, V >::Num ( )
inline

Definition at line 142 of file XrdOucRash.hh.

142{return rashnum;}

◆ Purge()

template<typename K, typename V>
void XrdOucRash< K, V >::Purge ( )

Definition at line 129 of file XrdOucRash.icc.

130{
131 int i;
132
133// Run through the major table and delete each item in the main table
134// the deletion automatically propagates.
135//
136 for (i = 0; i < 16; i++)
137 {if (rashTable[i].Item)
138 {delete rashTable[i].Item; rashTable[i].Item = 0;}
139 if (rashTable[i].Table)
140 {delete []rashTable[i].Table; rashTable[i].Table = 0;}
141 }
142 rashnum = 0;
143}

Referenced by ~XrdOucRash().

+ Here is the caller graph for this function:

◆ Rep()

template<typename K, typename V>
V * XrdOucRash< K, V >::Rep ( K KeyVal,
V & KeyData,
const int LifeTime = 0,
XrdOucRash_Options opt = Rash_default )
inline

Definition at line 150 of file XrdOucRash.hh.

152 {return Add(KeyVal, KeyData, LifeTime,
V * Add(K KeyVal, V &KeyData, time_t LifeTime=0, XrdOucRash_Options opt=Rash_default)

References Add(), Rash_default, and Rash_replace.

+ Here is the call graph for this function:

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