xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XrdClSIDManager.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_SID_MANAGER_HH__
20 #define __XRD_CL_SID_MANAGER_HH__
21 
22 #include <list>
23 #include <set>
24 #include <stdint.h>
25 #include "XrdSys/XrdSysPthread.hh"
26 #include "XrdCl/XrdClStatus.hh"
27 
28 namespace XrdCl
29 {
30  //----------------------------------------------------------------------------
32  //----------------------------------------------------------------------------
33  class SIDManager
34  {
35  public:
36 
37  //------------------------------------------------------------------------
39  //------------------------------------------------------------------------
41 
42  //------------------------------------------------------------------------
47  //------------------------------------------------------------------------
48  Status AllocateSID( uint8_t sid[2] );
49 
50  //------------------------------------------------------------------------
52  //------------------------------------------------------------------------
53  void ReleaseSID( uint8_t sid[2] );
54 
55  //------------------------------------------------------------------------
57  //------------------------------------------------------------------------
58  void TimeOutSID( uint8_t sid[2] );
59 
60  //------------------------------------------------------------------------
62  //------------------------------------------------------------------------
63  bool IsTimedOut( uint8_t sid[2] );
64 
65  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  void ReleaseTimedOut( uint8_t sid[2] );
69 
70  //------------------------------------------------------------------------
72  //------------------------------------------------------------------------
73  void ReleaseAllTimedOut();
74 
75  //------------------------------------------------------------------------
77  //------------------------------------------------------------------------
78  uint32_t NumberOfTimedOutSIDs() const
79  {
80  XrdSysMutexHelper scopedLock( pMutex );
81  return pTimeOutSIDs.size();
82  }
83 
84  //------------------------------------------------------------------------
86  //------------------------------------------------------------------------
87  uint16_t GetNumberOfAllocatedSIDs() const;
88 
89  private:
90  std::list<uint16_t> pFreeSIDs;
91  std::set<uint16_t> pTimeOutSIDs;
92  uint16_t pSIDCeiling;
94  };
95 }
96 
97 #endif // __XRD_CL_SID_MANAGER_HH__
bool IsTimedOut(uint8_t sid[2])
Check if a SID is timed out.
XrdSysMutex pMutex
Definition: XrdClSIDManager.hh:93
void TimeOutSID(uint8_t sid[2])
Register a SID of a request that timed out.
void ReleaseAllTimedOut()
Release all timed out SIDs.
Status AllocateSID(uint8_t sid[2])
Procedure execution status.
Definition: XrdClStatus.hh:109
Definition: XrdSysPthread.hh:165
uint16_t GetNumberOfAllocatedSIDs() const
Number of allocated streams.
uint32_t NumberOfTimedOutSIDs() const
Number of timeout sids.
Definition: XrdClSIDManager.hh:78
void ReleaseSID(uint8_t sid[2])
Release the SID that is no longer needed.
Handle XRootD stream IDs.
Definition: XrdClSIDManager.hh:33
std::set< uint16_t > pTimeOutSIDs
Definition: XrdClSIDManager.hh:91
std::list< uint16_t > pFreeSIDs
Definition: XrdClSIDManager.hh:90
uint16_t pSIDCeiling
Definition: XrdClSIDManager.hh:92
void ReleaseTimedOut(uint8_t sid[2])
Release a timed out SID.
Definition: XrdSysPthread.hh:260
SIDManager()
Constructor.
Definition: XrdClSIDManager.hh:40