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"
33 #include "XrdSsi/XrdSsiAtomics.hh"
34 #include "XrdSsi/XrdSsiRequest.hh"
35 
36 class XrdSsiPacer : public XrdJob
37 {
38 public:
39 
40 void DoIt() {Redrive();}
41 
42 void Hold(const char *reqID=0);
43 
44 void Q_Insert(XrdSsiPacer *Node)
45  {Node->next = next; // Chain in the item;
46  next->prev = Node;
47  next = Node;
48  Node->prev = this;
49  theQ->qCnt++;
50  }
51 
52 void Q_Remove()
53  {prev->next = next; // Unchain the item
54  next->prev = prev;
55  next = this;
56  prev = this;
57  theQ->qCnt--;
58  }
59 
60 void Q_PushBack(XrdSsiPacer *Node) {prev->Q_Insert(Node);}
61 
62 virtual void Redrive() {} // Meant to be overridden
63 
64 virtual
65 const char *RequestID() {return 0;} // Meant to be overridden
66 
67 void Reset();
68 
69 static void Run(XrdSsiRequest::RDR_Info &rInfo,
70  XrdSsiRequest::RDR_How rhow, const char *reqid=0);
71 
72 bool Singleton() {return next == this;}
73 
74  XrdSsiPacer() : prev(this), next(this), theQ(this),
75  qCnt(0), aCnt(0) {}
76 virtual ~XrdSsiPacer() {Reset();}
77 
78 private:
79 
85 int qCnt;
86 int aCnt;
87 };
88 #endif
XrdSsiAtomics.hh
XrdSsiPacer::next
XrdSsiPacer * next
Definition: XrdSsiPacer.hh:83
XrdSsiPacer::pMutex
static XrdSsiMutex pMutex
Definition: XrdSsiPacer.hh:80
XrdSsiPacer
Definition: XrdSsiPacer.hh:36
XrdSsiRequest.hh
XrdSsiPacer::Reset
void Reset()
XrdSsiPacer::Q_PushBack
void Q_PushBack(XrdSsiPacer *Node)
Definition: XrdSsiPacer.hh:60
XrdSsiPacer::Run
static void Run(XrdSsiRequest::RDR_Info &rInfo, XrdSsiRequest::RDR_How rhow, const char *reqid=0)
XrdSsiMutex
Definition: XrdSsiAtomics.hh:110
XrdSsiPacer::Singleton
bool Singleton()
Definition: XrdSsiPacer.hh:72
XrdSsiRequest::RDR_How
RDR_How
Definition: XrdSsiRequest.hh:254
XrdSsiPacer::qCnt
int qCnt
Definition: XrdSsiPacer.hh:85
XrdJob
Definition: XrdJob.hh:42
XrdSsiPacer::Redrive
virtual void Redrive()
Definition: XrdSsiPacer.hh:62
XrdSsiPacer::Hold
void Hold(const char *reqID=0)
XrdSsiPacer::Q_Remove
void Q_Remove()
Definition: XrdSsiPacer.hh:52
XrdSsiPacer::~XrdSsiPacer
virtual ~XrdSsiPacer()
Definition: XrdSsiPacer.hh:76
XrdSsiPacer::RequestID
virtual const char * RequestID()
Definition: XrdSsiPacer.hh:65
XrdSsiPacer::XrdSsiPacer
XrdSsiPacer()
Definition: XrdSsiPacer.hh:74
XrdSsiPacer::DoIt
void DoIt()
Definition: XrdSsiPacer.hh:40
XrdSsiPacer::prev
XrdSsiPacer * prev
Definition: XrdSsiPacer.hh:82
XrdJob.hh
XrdSsiPacer::glbQ
static XrdSsiPacer glbQ
Definition: XrdSsiPacer.hh:81
XrdSsiPacer::theQ
XrdSsiPacer * theQ
Definition: XrdSsiPacer.hh:84
XrdSsiPacer::aCnt
int aCnt
Definition: XrdSsiPacer.hh:86
XrdSsiPacer::Q_Insert
void Q_Insert(XrdSsiPacer *Node)
Definition: XrdSsiPacer.hh:44
XrdSsiRequest::RDR_Info
Definition: XrdSsiRequest.hh:256