xrootd
XrdBwmHandle.hh
Go to the documentation of this file.
1 #ifndef __BWM_HANDLE__
2 #define __BWM_HANDLE__
3 /******************************************************************************/
4 /* */
5 /* X r d B w m H a n d l e . 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 
13 #include <stdlib.h>
14 
15 #include "XrdBwm/XrdBwmPolicy.hh"
16 #include "XrdOuc/XrdOucErrInfo.hh"
17 #include "XrdSys/XrdSysPthread.hh"
18 
19 class XrdBwmLogger;
20 
22 {
23 public:
24 
26 
28 
29  int Activate(XrdOucErrInfo &einfo);
30 
31 static XrdBwmHandle *Alloc(const char *theUsr, const char *thePath,
32  const char *lclNode, const char *rmtNode,
33  int Incomming);
34 
35 static void *Dispatch();
36 
37 inline const char *Name() {return Parms.Lfn;}
38 
39  void Retire();
40 
41 static int setPolicy(XrdBwmPolicy *pP, XrdBwmLogger *lP);
42 
43  XrdBwmHandle() : Status(Idle), Next(0), qTime(0), rTime(0),
44  xSize(0), xTime(0)
45  {}
46 
48 
49 private:
50 static XrdBwmHandle *Alloc(XrdBwmHandle *oldHandle=0);
51 static XrdBwmHandle *refHandle(int refID, XrdBwmHandle *hP=0);
52 
55 static XrdBwmHandle *Free; // List of free handles
56 static unsigned int numQueued;
57 
62  unsigned long long ErrCBarg;
63  time_t qTime;
64  time_t rTime;
65  long long xSize;
66  long xTime;
67  int rHandle;
68 
69 class theEICB : public XrdOucEICB
70 {
71 public:
72 
73  void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
74  {mySem.Post();}
75 
76  int Same(unsigned long long arg1, unsigned long long arg2)
77  {return arg1 == arg2;}
78 
79  void Wait() {mySem.Wait();}
80 
81  theEICB() : mySem(0) {}
82 
83 virtual ~theEICB() {}
84 
85 private:
87 } myEICB;
88 };
89 #endif