Loading...
Searching...
No Matches
XrdObjectQ< T > Class Template Reference

`#include <XrdObject.hh>`

Inheritance diagram for XrdObjectQ< T >:
Collaboration diagram for XrdObjectQ< T >:

## Public Member Functions

| XrdObjectQ (const char *id, const char *desc)
| ~XrdObjectQ ()
void | DoIt ()
T * | Pop ()
void | Push (XrdObject< T > *Node)
void | Set (int inQMax, time_t agemax=1800)
void | Set (XrdScheduler *sp, XrdSysTrace *tp, int TraceChk=0)
Public Member Functions inherited from XrdJob
| XrdJob (const char *desc="")
virtual | ~XrdJob ()

## Additional Inherited Members

Public Attributes inherited from XrdJob
const char * | Comment
XrdJob * | NextJob

## Detailed Description

template<class T>
class XrdObjectQ< T >

Definition at line 89 of file XrdObject.hh.

## Constructor & Destructor Documentation

## XrdObjectQ()

template<class T>

XrdObjectQ< T >::XrdObjectQ | ( | const char * | id,
|  | const char * | desc )

inline

Definition at line 119 of file XrdObject.hh.

: XrdJob(desc)
{Curage = Count = 0; Maxage = 0; TraceID = id;
MaxinQ = 32; MininQ = 16; First = 0;
}
XrdJob::XrdJob
XrdJob(const char *desc="")
Definition XrdJob.hh:51
XrdObjectQ
Definition XrdObject.hh:90

References XrdJob::XrdJob().

Here is the call graph for this function:

## ~XrdObjectQ()

template<class T>

XrdObjectQ< T >::~XrdObjectQ | ( |  | ) |

inline

Definition at line 124 of file XrdObject.hh.

{}

## Member Function Documentation

## DoIt()

template<class T>

void XrdObjectQ< T >::DoIt | ( |  | ) |

virtual

Implements XrdJob.

Definition at line 38 of file XrdObject.icc.

{
XrdObject<T> *pp, *p;
int oldcnt, agemax;
// Lock the anchor and see if we met the threshold for deletion
//
QMutex.Lock();
agemax = Maxage;
if ((oldcnt = Count) > MininQ)
{
// Prepare to scan down the queue.
//
if ((pp = First)) p = pp->Next;
else p = 0;
// Find the first object that's been idle for too long
//
while(p && (p->QTime >= Curage)) {pp = p; p = p->Next;}
// Now delete half of the idle objects. The object queue element must be
// part of the actual object being deleted for this to properly work.
//
if (pp) while(p)
{pp->Next = p->Next; delete p->Item;
Count--;
p = ((pp = pp->Next) ? pp->Next : 0);
}
}
// Increase the age and unlock the queue
//
Curage++;
QMutex.UnLock();
// Trace as needed
//
if (TraceON && Trace->Tracing(TraceON))
{SYSTRACE(Trace->, 0, TraceID, 0,
Comment <<" trim done; " <<Count <<" of " <<oldcnt <<" kept");
}
// Reschedule ourselves if we must do so
//
if (agemax > 0) Sched->Schedule((XrdJob *)this, agemax+time(0));
}
SYSTRACE
#define SYSTRACE(obj, usr, epn, txt, dbg)
Definition XrdSysTrace.hh:45
XrdJob::Comment
const char * Comment
Definition XrdJob.hh:47

References XrdJob::XrdJob(), XrdJob::Comment, and SYSTRACE.

Here is the call graph for this function:

## Pop()

template<class T>

T * XrdObjectQ< T >::Pop | ( |  | ) |

inline

Definition at line 93 of file XrdObject.hh.

{XrdObject<T> *Node;
QMutex.Lock();
if ((Node = First)) {First = First->Next; Count--;}
QMutex.UnLock();
if (Node) return Node->Item;
return (T *)0;
}

## Push()

template<class T>

void XrdObjectQ< T >::Push | ( | XrdObject< T > * | Node | ) |

inline

Definition at line 101 of file XrdObject.hh.

{Node->QTime = Curage;
QMutex.Lock();
if (Count >= MaxinQ) delete Node->Item;
else {Node->Next = First;
First = Node;
Count++;
}
QMutex.UnLock();
}

## Set() [1/2]

template<class T>

void XrdObjectQ< T >::Set | ( | int | inQMax,
|  | time_t | agemax = 1800 )

Definition at line 90 of file XrdObject.icc.

{
// Lock the data area and set the values
//
QMutex.Lock();
MaxinQ = inQMax; Maxage = agemax;
if (!(MininQ = inQMax/2)) MininQ = 1;
QMutex.UnLock();
// Schedule ourselves using the new values
//
if (agemax > 0) Sched->Schedule((XrdJob *)this, agemax+time(0));
}

References XrdJob::XrdJob().

Here is the call graph for this function:

## Set() [2/2]

template<class T>

void XrdObjectQ< T >::Set | ( | XrdScheduler * | sp,
|  | XrdSysTrace * | tp,
|  | int | TraceChk = 0 )

inline

Definition at line 114 of file XrdObject.hh.

{Sched = sp; Trace = tp; TraceON = TraceChk;}

References XrdJob::XrdScheduler.

Here is the call graph for this function:

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

- XrdObject.hh
- XrdObject.icc