00001 #ifndef __CMS_CLIENTMSG__ 00002 #define __CMS_CLIENTMSG__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s C l i e n t M s g . h h */ 00006 /* */ 00007 /* (c) 2007 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: XrdCmsClientMsg.hh 38011 2011-02-08 18:35:57Z ganis $ 00014 00015 #include "XProtocol/YProtocol.hh" 00016 00017 #include "XrdSys/XrdSysPthread.hh" 00018 00019 class XrdOucErrInfo; 00020 class XrdNetBuffer; 00021 00022 class XrdCmsClientMsg 00023 { 00024 public: 00025 00026 static XrdCmsClientMsg *Alloc(XrdOucErrInfo *erp); 00027 00028 inline int getResult() {return Result;} 00029 00030 inline int ID() {return id;} 00031 00032 static int Init(); 00033 00034 static int inQ() {return numinQ;} 00035 00036 void Lock() {Hold.Lock();} 00037 00038 void Recycle(); 00039 00040 static int Reply(const char *Man,XrdCms::CmsRRHdr &hdr,XrdNetBuffer *buff); 00041 00042 void UnLock() {Hold.UnLock();} 00043 00044 int Wait4Reply(int wtime) {return Hold.Wait(wtime);} 00045 00046 XrdCmsClientMsg() : Hold(0) {next = 0; inwaitq = 0; Resp = 0; Result = 0;} 00047 ~XrdCmsClientMsg() {} 00048 00049 private: 00050 static const int MidMask = 1023; 00051 static const int MaxMsgs = 1024; 00052 static const int MidIncr = 1024; 00053 static const int IncMask = 0x3ffffc00; 00054 static XrdCmsClientMsg *RemFromWaitQ(int msgid); 00055 00056 static int nextid; 00057 static int numinQ; 00058 00059 static XrdCmsClientMsg *msgTab; 00060 static XrdCmsClientMsg *nextfree; 00061 static XrdSysMutex FreeMsgQ; 00062 00063 XrdCmsClientMsg *next; 00064 XrdSysCondVar Hold; 00065 int inwaitq; 00066 int id; 00067 XrdOucErrInfo *Resp; 00068 int Result; 00069 }; 00070 #endif