Logo ROOT   6.10/09
Reference Guide
XrdClientInputBuffer.hh
Go to the documentation of this file.
1 #ifndef XRC_INPUTBUFFER_H
2 #define XRC_INPUTBUFFER_H
3 /******************************************************************************/
4 /* */
5 /* X r d C l i e n t I n p u t B u f f e r . h h */
6 /* */
7 /* Author: Fabrizio Furano (INFN Padova, 2004) */
8 /* Adapted from TXNetFile (root.cern.ch) originally done by */
9 /* Alvise Dorigo, Fabrizio Furano */
10 /* INFN Padova, 2003 */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 //////////////////////////////////////////////////////////////////////////
34 // //
35 // Buffer for incoming messages (responses) //
36 // Handles the waiting (with timeout) for a message to come //
37 // belonging to a logical streamid //
38 // Multithread friendly //
39 // //
40 //////////////////////////////////////////////////////////////////////////
41 
43 #include "XrdSys/XrdSysPthread.hh"
44 #include "XrdSys/XrdSysSemWait.hh"
45 #include "XrdOuc/XrdOucHash.hh"
47 
48 using namespace std;
49 
51 
52 private:
53 
54  XrdClientVector<XrdClientMessage*> fMsgQue; // queue for incoming messages
55  int fMsgIter; // an iterator on it
56 
57  XrdSysRecMutex fMutex; // mutex to protect data structures
58 
59  XrdOucHash<XrdSysSemWait> fSyncobjRepo;
60  // each streamid counts on a condition
61  // variable to make the caller wait
62  // until some data is available
63 
64 
65  XrdSysSemWait *GetSyncObjOrMakeOne(int streamid);
66 
67  int MsgForStreamidCnt(int streamid);
68 
69 public:
72 
73  inline bool IsMexEmpty() { return (MexSize() == 0); }
74  inline bool IsSemEmpty() { return (SemSize() == 0); }
75  inline int MexSize() {
76  XrdSysMutexHelper mtx(fMutex);
77  return fMsgQue.GetSize();
78  }
79  int PutMsg(XrdClientMessage *msg);
80  inline int SemSize() {
81  XrdSysMutexHelper mtx(fMutex);
82  return fSyncobjRepo.Num();
83  }
84 
85  int WipeStreamid(int streamid);
86 
87  XrdClientMessage *GetMsg(int streamid, int secstimeout);
88 };
89 #endif
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
STL namespace.
int GetSize() const
#define XrdSysSemWait
Definition: XpdSysSemWait.h:8
XrdOucHash< XrdSysSemWait > fSyncobjRepo
#define XrdSysMutexHelper
Definition: XrdSysToOuc.h:17
XrdClientVector< XrdClientMessage * > fMsgQue