XrdOucSid Class Reference

#include <XrdOucSid.hh>

Collaboration diagram for XrdOucSid:
Collaboration graph
[legend]

List of all members.

Classes

union  theSid
 The type to pass to Obtain(). Simply cast the char[2] to (theSid *). More...

Public Member Functions

bool Obtain (theSid *sidP)
bool Release (theSid *sidP)
void Reset ()
 XrdOucSid (int numSid=256, bool mtproof=true, XrdOucSid *glblSid=0)
 ~XrdOucSid ()

Private Attributes

XrdSysMutex sidMutex
XrdOucSidglobalSid
unsigned char * sidVec
int sidFree
int sidSize
int sidMax
bool sidLock

Detailed Description

This class implements a fast bit vector based stream ID generator. When stream ID's are generated on a connection basis, each connection can allocate a local SID object sizing the bit vector to match the expected number of simultaneous stream ID's in order to save memory. In order to accomodate overflows, the local object can be initialized with a global SID object that be used to obtain stream ID's when the local object runs out. See the constructor description for the details.


Constructor & Destructor Documentation

XrdOucSid::XrdOucSid ( int  numSid = 256,
bool  mtproof = true,
XrdOucSid glblSid = 0 
)

Constructor

Parameters:
numSid the maximum number of stream ID's that this object can allocate. The value is rounded up to the next multiple of eight. Every 8 ID's requires one byte of memory. Normally, stream ID's range from 0 to 32767, though technically can go to 64K-1 but are then represented as a negative short.
mtproof When true (the default) the object obtains a lock before doing any operations. When false, it does not and must be protected, if need be, by some other serialization.
glblSid a pointer to another SID object that can be used to obtain stream ID's should this object run out of them. Typically, this is a global pool of stream ID's.
XrdOucSid::~XrdOucSid (  ) 

Destructor. Only this object is destroyed. The global object, if any, is not alteered in any way.


Member Function Documentation

bool XrdOucSid::Obtain ( theSid sidP  ) 

Obtain a stream ID. When not needed use Release() to recycle them.

Parameters:
sidP -> the place where the new stream ID is to be placed.
Returns:
true a stream ID was allocated.
false no more stream ID's are available. The sidP target was not altered (i.e. does not contain a stream ID).

Referenced by XrdPssUrlInfo::setID().

bool XrdOucSid::Release ( theSid sidP  ) 

Release a stream ID using the stream ID value.

Parameters:
sidP -> to the stream ID cast as a theSid pointer.
Returns:
true the stream ID was released and may be reassigned.
false the stream ID is invalid. No action performed.

Referenced by XrdPssUrlInfo::~XrdPssUrlInfo().

void XrdOucSid::Reset (  ) 

Unassign all stream ID's as if the object were newly allocated. Any global stream ID object associated with this object is *not* reset.


Member Data Documentation

int XrdOucSid::sidFree [private]
bool XrdOucSid::sidLock [private]
int XrdOucSid::sidMax [private]
int XrdOucSid::sidSize [private]
unsigned char* XrdOucSid::sidVec [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 13 May 2020 for xrootd by  doxygen 1.6.1