xrootd
XrdSsiPacer.hh
Go to the documentation of this file.
1#ifndef __XRDSSIPACER_HH__
2#define __XRDSSIPACER_HH__
3/******************************************************************************/
4/* */
5/* X r d S s i P a c e r . h h */
6/* */
7/* (c) 2016 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include "Xrd/XrdJob.hh"
35
36class XrdSsiPacer : public XrdJob
37{
38public:
39
40void DoIt() {Redrive();}
41
42void Hold(const char *reqID=0);
43
45 {Node->next = next; // Chain in the item;
46 next->prev = Node;
47 next = Node;
48 Node->prev = this;
49 theQ->qCnt++;
50 }
51
53 {prev->next = next; // Unchain the item
54 next->prev = prev;
55 next = this;
56 prev = this;
57 theQ->qCnt--;
58 }
59
60void Q_PushBack(XrdSsiPacer *Node) {prev->Q_Insert(Node);}
61
62virtual void Redrive() {} // Meant to be overridden
63
64virtual
65const char *RequestID() {return 0;} // Meant to be overridden
66
67void Reset();
68
69static void Run(XrdSsiRequest::RDR_Info &rInfo,
70 XrdSsiRequest::RDR_How rhow, const char *reqid=0);
71
72bool Singleton() {return next == this;}
73
74 XrdSsiPacer() : prev(this), next(this), theQ(this),
75 qCnt(0), aCnt(0) {}
76virtual ~XrdSsiPacer() {Reset();}
77
78private:
79
85int qCnt;
86int aCnt;
87};
88#endif
Definition: XrdJob.hh:43
Definition: XrdSsiAtomics.hh:111
Definition: XrdSsiPacer.hh:37
void DoIt()
Definition: XrdSsiPacer.hh:40
void Reset()
void Q_PushBack(XrdSsiPacer *Node)
Definition: XrdSsiPacer.hh:60
bool Singleton()
Definition: XrdSsiPacer.hh:72
int aCnt
Definition: XrdSsiPacer.hh:86
XrdSsiPacer * theQ
Definition: XrdSsiPacer.hh:84
static XrdSsiPacer glbQ
Definition: XrdSsiPacer.hh:81
static XrdSsiMutex pMutex
Definition: XrdSsiPacer.hh:80
void Q_Insert(XrdSsiPacer *Node)
Definition: XrdSsiPacer.hh:44
XrdSsiPacer * next
Definition: XrdSsiPacer.hh:83
virtual ~XrdSsiPacer()
Definition: XrdSsiPacer.hh:76
virtual void Redrive()
Definition: XrdSsiPacer.hh:62
static void Run(XrdSsiRequest::RDR_Info &rInfo, XrdSsiRequest::RDR_How rhow, const char *reqid=0)
void Q_Remove()
Definition: XrdSsiPacer.hh:52
void Hold(const char *reqID=0)
XrdSsiPacer * prev
Definition: XrdSsiPacer.hh:82
int qCnt
Definition: XrdSsiPacer.hh:85
XrdSsiPacer()
Definition: XrdSsiPacer.hh:74
virtual const char * RequestID()
Definition: XrdSsiPacer.hh:65
RDR_How
Definition: XrdSsiRequest.hh:254
Definition: XrdSsiRequest.hh:256