• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

XrdOdcResp.hh

Go to the documentation of this file.
00001 #ifndef __ODC_RESP__
00002 #define __ODC_RESP__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                         X r d O d c r e s p . h h                          */
00006 /*                                                                            */
00007 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012   
00013 //          $Id: XrdOdcResp.hh,v 1.3 2009/12/24 02:07:48 abh Exp $
00014 
00015 #include "XrdOuc/XrdOucErrInfo.hh"
00016 #include "XrdSys/XrdSysPthread.hh"
00017 
00018 /******************************************************************************/
00019 /*                          X r d O d c R e s p C B                           */
00020 /******************************************************************************/
00021   
00022 class XrdOdcRespCB : XrdOucEICB
00023 {
00024 public:
00025 
00026 void Done(int &Result, XrdOucErrInfo *eInfo) {respSync.Post();}
00027 
00028 void Init() {while(respSync.CondWait()) {}}
00029 
00030 int  Same(unsigned long long arg1, unsigned long long arg2) {return 0;}
00031 
00032 void Wait() {respSync.Wait();}
00033 
00034      XrdOdcRespCB() : respSync(0) {}
00035     ~XrdOdcRespCB() {}
00036 
00037 private:
00038 
00039 XrdSysSemaphore     respSync;
00040 };
00041 
00042 /******************************************************************************/
00043 /*                            X r d O d c R e s p                             */
00044 /******************************************************************************/
00045   
00046 class XrdOdcResp : public XrdOucErrInfo, public XrdOucEICB
00047 {
00048 public:
00049 friend class XrdOdcRespQ;
00050 
00051 static XrdOdcResp *Alloc(XrdOucErrInfo *erp, int msgid);
00052 
00053        void        Done(int &Result, XrdOucErrInfo *eInfo) {Recycle();}
00054 
00055 inline int         ID() {return myID;}
00056 
00057        void        Reply(const char *Man, char *reply);
00058 
00059        int         Same(unsigned long long arg1, unsigned long long arg2)
00060                        {return 0;}
00061 
00062 static void        setDelay(int repdly) {RepDelay = repdly;}
00063 
00064        XrdOdcResp() : XrdOucErrInfo(UserID) {next = 0;}
00065       ~XrdOdcResp() {}
00066 
00067 private:
00068        void Recycle();
00069 
00070 static XrdOdcResp            *nextFree;
00071 static XrdSysMutex            myMutex;  // Protects above and below
00072 static int                    numFree;
00073 static const int              maxFree = 300;
00074 static int                    RepDelay;
00075 
00076 XrdOdcRespCB        SyncCB;
00077 XrdOdcResp         *next;
00078 int                 myID;
00079 char                UserID[64];
00080 };
00081   
00082 /******************************************************************************/
00083 /*                           X r d O d c R e s p Q                            */
00084 /******************************************************************************/
00085   
00086 class XrdOdcRespQ
00087 {
00088 public:
00089        void        Add(XrdOdcResp *rp);
00090 
00091        void        Purge();
00092 
00093        XrdOdcResp *Rem(int msgid);
00094 
00095        XrdOdcRespQ();
00096       ~XrdOdcRespQ() {Purge();}
00097 
00098 private:
00099 
00100        XrdSysMutex            myMutex;  // Protects above and below
00101 static const int              mqSize = 512;
00102 
00103 XrdOdcResp         *mqTab[mqSize];
00104 };
00105 #endif

Generated on Wed Sep 1 2010 for xrootd by  doxygen 1.7.1