xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdBwm
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
36
class
XrdBwmPolicy1
:
public
XrdBwmPolicy
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);
49
~XrdBwmPolicy1
() {}
50
51
enum
Flow
{
In
= 0,
Out
= 1,
Xeq
= 2,
IOX
= 3};
52
53
struct
refReq
54
{
refReq
*
Next
;
55
int
refID
;
56
Flow
Way
;
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
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
104
XrdSysSemaphore
pSem
;
105
XrdSysMutex
pMutex
;
106
int
refID
;
107
};
108
#endif
Generated by
1.8.3.1