00001 #ifndef __ODC_MSG__ 00002 #define __ODC_MSG__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O d c M s g . h h */ 00006 /* */ 00007 /* (c) 2003 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-AC03-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id: XrdOdcMsg.hh,v 1.7 2007/07/26 15:18:20 ganis Exp $ 00014 00015 #include "XrdSys/XrdSysPthread.hh" 00016 00017 class XrdOucErrInfo; 00018 00019 class XrdOdcMsg 00020 { 00021 public: 00022 00023 static XrdOdcMsg *Alloc(XrdOucErrInfo *erp); 00024 00025 inline int ID() {return id;} 00026 00027 static int Init(); 00028 00029 void Lock() {Hold.Lock();} 00030 00031 static int mapError(const char *ecode); 00032 00033 void Recycle(); 00034 00035 static int Reply(int msgid, char *reply); 00036 00037 void UnLock() {Hold.UnLock();} 00038 00039 int Wait4Reply(int wtime) {return Hold.Wait(wtime);} 00040 00041 XrdOdcMsg() : Hold(0) {inwaitq = 0; Resp = 0; next = 0;} 00042 ~XrdOdcMsg() {} 00043 00044 private: 00045 static XrdOdcMsg *RemFromWaitQ(int msgid); 00046 00047 static int nextid; 00048 00049 static XrdOdcMsg *msgTab; 00050 static XrdOdcMsg *nextfree; 00051 static XrdSysMutex FreeMsgQ; 00052 00053 XrdOdcMsg *next; 00054 XrdSysCondVar Hold; 00055 int inwaitq; 00056 int id; 00057 XrdOucErrInfo *Resp; 00058 }; 00059 #endif
1.7.1