XRootD
Loading...
Searching...
No Matches
XrdBwmPolicy1 Class Reference

#include <XrdBwmPolicy1.hh>

+ Inheritance diagram for XrdBwmPolicy1:
+ Collaboration diagram for XrdBwmPolicy1:

Classes

struct  refReq
 

Public Types

enum  Flow {
  In = 0 ,
  Out = 1 ,
  Xeq = 2 ,
  IOX = 3
}
 
- Public Types inherited from XrdBwmPolicy
enum  Flow {
  Incoming = 0 ,
  Outgoing
}
 

Public Member Functions

 XrdBwmPolicy1 (int inslots, int outslots)
 
 ~XrdBwmPolicy1 ()
 
int Dispatch (char *RespBuff, int RespSize)
 
int Done (int rHandle)
 
int Schedule (char *RespBuff, int RespSize, SchedParms &Parms)
 
void Status (int &numqIn, int &numqOut, int &numXeq)
 
- Public Member Functions inherited from XrdBwmPolicy
 XrdBwmPolicy ()
 
virtual ~XrdBwmPolicy ()
 

Detailed Description

Definition at line 36 of file XrdBwmPolicy1.hh.

Member Enumeration Documentation

◆ Flow

Enumerator
In 
Out 
Xeq 
IOX 

Definition at line 51 of file XrdBwmPolicy1.hh.

Constructor & Destructor Documentation

◆ XrdBwmPolicy1()

XrdBwmPolicy1::XrdBwmPolicy1 ( int inslots,
int outslots )

Definition at line 39 of file XrdBwmPolicy1.cc.

40{
41// Initialize values
42//
43 theQ[In ].maxSlots = theQ[In ].curSlots = inslots;
44 theQ[Out].maxSlots = theQ[Out].curSlots = outslots;
45 theQ[Xeq].maxSlots = theQ[Xeq].curSlots = 0;
46 refID = 1;
47}

References In, Out, and Xeq.

◆ ~XrdBwmPolicy1()

XrdBwmPolicy1::~XrdBwmPolicy1 ( )
inline

Definition at line 49 of file XrdBwmPolicy1.hh.

49{}

Member Function Documentation

◆ Dispatch()

int XrdBwmPolicy1::Dispatch ( char * RespBuff,
int RespSize )
virtual

Implements XrdBwmPolicy.

Definition at line 53 of file XrdBwmPolicy1.cc.

54{
55 refReq *rP;
56 int rID;
57
58// Obtain mutex and check if we have any queued requests
59//
60 do {pMutex.Lock();
61 if ((rP = theQ[In].Next()) || (rP = theQ[Out].Next()))
62 {theQ[Xeq].Add(rP);
63 rID = rP->refID; *RespBuff = '\0';
64 pMutex.UnLock();
65 return rID;
66 }
67 pMutex.UnLock();
68 pSem.Wait();
69 } while(1);
70
71// Should never get here
72//
73 strcpy(RespBuff, "Fatal logic error!");
74 return 0;
75}

References In, XrdSysMutex::Lock(), Out, XrdBwmPolicy1::refReq::refID, XrdSysMutex::UnLock(), XrdSysSemaphore::Wait(), and Xeq.

+ Here is the call graph for this function:

◆ Done()

int XrdBwmPolicy1::Done ( int rHandle)
virtual

Implements XrdBwmPolicy.

Definition at line 81 of file XrdBwmPolicy1.cc.

82{
83 refReq *rP;
84 int rc;
85
86// Make sure we have a positive value here
87//
88 if (rHandle < 0) rHandle = -rHandle;
89
90// Remove the element from whichever queue it is in
91//
92 pMutex.Lock();
93 if ((rP = theQ[Xeq].Yank(rHandle)))
94 {if (theQ[rP->Way].curSlots++ == 0) pSem.Post();
95 rc = 1;
96 } else {
97 if ((rP=theQ[In].Yank(rHandle)) || (rP=theQ[Out].Yank(rHandle))) rc = -1;
98 else rc = 0;
99 }
100 pMutex.UnLock();
101
102// delete the element and return
103//
104 if (rP) delete rP;
105 return rc;
106}

References In, XrdSysMutex::Lock(), Out, XrdSysSemaphore::Post(), XrdSysMutex::UnLock(), XrdBwmPolicy1::refReq::Way, and Xeq.

+ Here is the call graph for this function:

◆ Schedule()

int XrdBwmPolicy1::Schedule ( char * RespBuff,
int RespSize,
SchedParms & Parms )
virtual

Implements XrdBwmPolicy.

Definition at line 112 of file XrdBwmPolicy1.cc.

113{
114 static const char *theWay[] = {"Incoming", "Outgoing"};
115 refReq *rP;
116 int myID;
117
118// Get the global lock and generate a reference ID
119//
120 *RespBuff = '\0';
121 pMutex.Lock();
122 myID = ++refID;
123 rP = new refReq(myID, Parms.Direction);
124
125// Check if we can immediately schedule this requestor must defer it
126//
127 if (theQ[rP->Way].curSlots > 0)
128 {theQ[rP->Way].curSlots--;
129 theQ[Xeq].Add(rP);
130 }
131 else if (theQ[rP->Way].maxSlots)
132 {theQ[rP->Way].Add(rP); myID = -myID;}
133 else {strcpy(RespBuff, theWay[rP->Way]);
134 strcat(RespBuff, " requests are not allowed.");
135 delete rP;
136 myID = 0;
137 }
138
139// All done
140//
141 pMutex.UnLock();
142 return myID;
143}

References XrdBwmPolicy::SchedParms::Direction, XrdSysMutex::Lock(), XrdSysMutex::UnLock(), XrdBwmPolicy1::refReq::Way, and Xeq.

+ Here is the call graph for this function:

◆ Status()

void XrdBwmPolicy1::Status ( int & numqIn,
int & numqOut,
int & numXeq )
virtual

Implements XrdBwmPolicy.

Definition at line 149 of file XrdBwmPolicy1.cc.

150{
151
152// Get the global lock and return the values
153//
154 pMutex.Lock();
155 numqIn = theQ[In ].Num;
156 numqOut = theQ[Out].Num;
157 numXeq = theQ[Xeq].Num;
158 pMutex.UnLock();
159}

References In, XrdSysMutex::Lock(), Out, XrdSysMutex::UnLock(), and Xeq.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: