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

enum XrdBwmPolicy1::Flow

Enumerator
In |
Out |
Xeq |
IOX |

Definition at line 51 of file XrdBwmPolicy1.hh.

{In = 0, Out = 1, Xeq = 2, IOX = 3};
XrdBwmPolicy1::IOX
@ IOX
Definition XrdBwmPolicy1.hh:51
XrdBwmPolicy1::Xeq
@ Xeq
Definition XrdBwmPolicy1.hh:51
XrdBwmPolicy1::In
@ In
Definition XrdBwmPolicy1.hh:51
XrdBwmPolicy1::Out
@ Out
Definition XrdBwmPolicy1.hh:51

## Constructor & Destructor Documentation

## XrdBwmPolicy1()

XrdBwmPolicy1::XrdBwmPolicy1 | ( | int | inslots,
|  | int | outslots )

Definition at line 39 of file XrdBwmPolicy1.cc.

{
// Initialize values
//
theQ[In ].maxSlots = theQ[In ].curSlots = inslots;
theQ[Out].maxSlots = theQ[Out].curSlots = outslots;
theQ[Xeq].maxSlots = theQ[Xeq].curSlots = 0;
refID = 1;
}

References In, Out, and Xeq.

## ~XrdBwmPolicy1()

XrdBwmPolicy1::~XrdBwmPolicy1 | ( |  | ) |

inline

Definition at line 49 of file XrdBwmPolicy1.hh.

{}

## Member Function Documentation

## Dispatch()

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

virtual

Implements XrdBwmPolicy.

Definition at line 53 of file XrdBwmPolicy1.cc.

{
refReq *rP;
int rID;
// Obtain mutex and check if we have any queued requests
//
do {pMutex.Lock();
if ((rP = theQ[In].Next()) || (rP = theQ[Out].Next()))
{theQ[Xeq].Add(rP);
rID = rP->refID; *RespBuff = '\0';
pMutex.UnLock();
return rID;
}
pMutex.UnLock();
pSem.Wait();
} while(1);
// Should never get here
//
strcpy(RespBuff, "Fatal logic error!");
return 0;
}
XrdBwmPolicy1::refReq
Definition XrdBwmPolicy1.hh:54

References In, Out, XrdBwmPolicy1::refReq::refID, and Xeq.

## Done()

int XrdBwmPolicy1::Done | ( | int | rHandle | ) |

virtual

Implements XrdBwmPolicy.

Definition at line 81 of file XrdBwmPolicy1.cc.

{
refReq *rP;
int rc;
// Make sure we have a positive value here
//
if (rHandle < 0) rHandle = -rHandle;
// Remove the element from whichever queue it is in
//
pMutex.Lock();
if ((rP = theQ[Xeq].Yank(rHandle)))
{if (theQ[rP->Way].curSlots++ == 0) pSem.Post();
rc = 1;
} else {
if ((rP=theQ[In].Yank(rHandle)) || (rP=theQ[Out].Yank(rHandle))) rc = -1;
else rc = 0;
}
pMutex.UnLock();
// delete the element and return
//
if (rP) delete rP;
return rc;
}

References In, Out, XrdBwmPolicy1::refReq::Way, and Xeq.

## Schedule()

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

virtual

Implements XrdBwmPolicy.

Definition at line 112 of file XrdBwmPolicy1.cc.

{
static const char *theWay[] = {"Incoming", "Outgoing"};
refReq *rP;
int myID;
// Get the global lock and generate a reference ID
//
*RespBuff = '\0';
pMutex.Lock();
myID = ++refID;
rP = new refReq(myID, Parms.Direction);
// Check if we can immediately schedule this requestor must defer it
//
if (theQ[rP->Way].curSlots > 0)
{theQ[rP->Way].curSlots--;
theQ[Xeq].Add(rP);
}
else if (theQ[rP->Way].maxSlots)
{theQ[rP->Way].Add(rP); myID = -myID;}
else {strcpy(RespBuff, theWay[rP->Way]);
strcat(RespBuff, " requests are not allowed.");
delete rP;
myID = 0;
}
// All done
//
pMutex.UnLock();
return myID;
}

References XrdBwmPolicy::SchedParms::Direction, XrdBwmPolicy1::refReq::Way, and Xeq.

## Status()

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

virtual

Implements XrdBwmPolicy.

Definition at line 149 of file XrdBwmPolicy1.cc.

{
// Get the global lock and return the values
//
pMutex.Lock();
numqIn = theQ[In ].Num;
numqOut = theQ[Out].Num;
numXeq = theQ[Xeq].Num;
pMutex.UnLock();
}

References In, Out, and Xeq.

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

- XrdBwmPolicy1.hh
- XrdBwmPolicy1.cc