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,v 1.1 2007/11/16 01:04:44 abh Exp $ 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 void Lock() {Hold.Lock();} 00035 00036 void Recycle(); 00037 00038 static int Reply(const char *Man,XrdCms::CmsRRHdr &hdr,XrdNetBuffer *buff); 00039 00040 void UnLock() {Hold.UnLock();} 00041 00042 int Wait4Reply(int wtime) {return Hold.Wait(wtime);} 00043 00044 XrdCmsClientMsg() : Hold(0) {next = 0; inwaitq = 0; Resp = 0; Result = 0;} 00045 ~XrdCmsClientMsg() {} 00046 00047 private: 00048 static const int MidMask = 1023; 00049 static const int MaxMsgs = 1024; 00050 static const int MidIncr = 1024; 00051 static const int IncMask = 0x3ffffc00; 00052 static XrdCmsClientMsg *RemFromWaitQ(int msgid); 00053 00054 static int nextid; 00055 00056 static XrdCmsClientMsg *msgTab; 00057 static XrdCmsClientMsg *nextfree; 00058 static XrdSysMutex FreeMsgQ; 00059 00060 XrdCmsClientMsg *next; 00061 XrdSysCondVar Hold; 00062 int inwaitq; 00063 int id; 00064 XrdOucErrInfo *Resp; 00065 int Result; 00066 }; 00067 #endif
1.7.1