XRootD
Loading...
Searching...
No Matches
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
35
37{
38public:
39
40int Dispatch(char *RespBuff, int RespSize);
41
42int Done(int rHandle);
43
44int Schedule(char *RespBuff, int RespSize, SchedParms &Parms);
45
46void Status(int &numqIn, int &numqOut, int &numXeq);
47
48 XrdBwmPolicy1(int inslots, int outslots);
50
51enum Flow {In = 0, Out = 1, Xeq = 2, IOX = 3};
52
53struct refReq
55 int refID;
57
58 refReq(int id, XrdBwmPolicy::Flow xF) : Next(0), refID(id),
59 Way(xF == XrdBwmPolicy::Incoming ? In : Out) {}
61 };
62
63private:
64
65class refSch
66 {public:
67
68 refReq *First;
69 refReq *Last;
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
104XrdSysSemaphore pSem;
105XrdSysMutex pMutex;
106int refID;
107};
108#endif
int Dispatch(char *RespBuff, int RespSize)
void Status(int &numqIn, int &numqOut, int &numXeq)
int Schedule(char *RespBuff, int RespSize, SchedParms &Parms)
int Done(int rHandle)
refReq(int id, XrdBwmPolicy::Flow xF)