xrootd
XrdBwmPolicy1.hh
Go to the documentation of this file.
1 #ifndef __BWM_POLICY1_HH__
2 #define __BWM_POLICY1_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d B w m P o l i c y 1 . h h */
6 /* */
7 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include "XrdBwm/XrdBwmPolicy.hh"
34 #include "XrdSys/XrdSysPthread.hh"
35 
37 {
38 public:
39 
40 int Dispatch(char *RespBuff, int RespSize);
41 
42 int Done(int rHandle);
43 
44 int Schedule(char *RespBuff, int RespSize, SchedParms &Parms);
45 
46 void Status(int &numqIn, int &numqOut, int &numXeq);
47 
48  XrdBwmPolicy1(int inslots, int outslots);
50 
51 enum Flow {In = 0, Out = 1, Xeq = 2, IOX = 3};
52 
53 struct refReq
55  int refID;
57 
58  refReq(int id, XrdBwmPolicy::Flow xF) : Next(0), refID(id),
59  Way(xF == XrdBwmPolicy::Incomming ? In : Out) {}
60  ~refReq() {}
61  };
62 
63 private:
64 
65 class refSch
66  {public:
67 
70  int Num;
71  int curSlots;
72  int maxSlots;
73 
74  void Add(refReq *rP)
75  {if ((rP->Next = Last)) Last = rP;
76  else First= Last = rP;
77  Num++;
78  }
79 
80  refReq *Next() {refReq *rP;
81  if ((rP = First) && curSlots)
82  {if (!(First = First->Next)) Last = 0;
83  Num--; curSlots--;
84  }
85  return rP;
86  }
87 
88  refReq *Yank(int rID)
89  {refReq *pP = 0, *rP = First;
90  while(rP && rID != rP->refID) {pP = rP; rP = rP->Next;}
91  if (rP)
92  {if (pP) pP->Next = rP->Next;
93  else First = rP->Next;
94  if (rP == Last) Last = pP;
95  Num--;
96  }
97  return rP;
98  }
99 
100  refSch() : First(0), Last(0), Num(0) {}
101  ~refSch() {} // Never deleted!
102  } theQ[IOX];
103 
106 int refID;
107 };
108 #endif
class XrdBwmPolicy1::refSch theQ[IOX]
~refSch()
Definition: XrdBwmPolicy1.hh:101
Definition: XrdBwmPolicy1.hh:65
Flow Way
Definition: XrdBwmPolicy1.hh:56
XrdSysSemaphore pSem
Definition: XrdBwmPolicy1.hh:104
Definition: XrdBwmPolicy.hh:115
refReq * Last
Definition: XrdBwmPolicy1.hh:69
int maxSlots
Definition: XrdBwmPolicy1.hh:72
Definition: XrdBwmPolicy1.hh:51
refReq * Next
Definition: XrdBwmPolicy1.hh:54
Flow
Definition: XrdBwmPolicy.hh:115
refReq(int id, XrdBwmPolicy::Flow xF)
Definition: XrdBwmPolicy1.hh:58
Definition: XrdBwmPolicy.hh:117
int curSlots
Definition: XrdBwmPolicy1.hh:71
Definition: XrdSysPthread.hh:165
Definition: XrdBwmPolicy1.hh:51
int Num
Definition: XrdBwmPolicy1.hh:70
Definition: XrdBwmPolicy1.hh:36
Definition: XrdBwmPolicy.hh:33
int refID
Definition: XrdBwmPolicy1.hh:55
Definition: XrdSysPthread.hh:405
Flow
Definition: XrdBwmPolicy1.hh:51
Definition: XrdBwmPolicy1.hh:51
XrdBwmPolicy1(int inslots, int outslots)
int Dispatch(char *RespBuff, int RespSize)
int Schedule(char *RespBuff, int RespSize, SchedParms &Parms)
int refID
Definition: XrdBwmPolicy1.hh:106
~XrdBwmPolicy1()
Definition: XrdBwmPolicy1.hh:49
XrdSysMutex pMutex
Definition: XrdBwmPolicy1.hh:105
void Add(refReq *rP)
Definition: XrdBwmPolicy1.hh:74
~refReq()
Definition: XrdBwmPolicy1.hh:60
refReq * Yank(int rID)
Definition: XrdBwmPolicy1.hh:88
void Status(int &numqIn, int &numqOut, int &numXeq)
refReq * First
Definition: XrdBwmPolicy1.hh:68
refSch()
Definition: XrdBwmPolicy1.hh:100
Definition: XrdBwmPolicy1.hh:51
int Done(int rHandle)
refReq * Next()
Definition: XrdBwmPolicy1.hh:80
Definition: XrdBwmPolicy1.hh:53