![]() |
XRootD
|
#include <XrdOucSid.hh>
Classes | |
union | theSid |
The type to pass to Obtain(). Simply cast the char[2] to (theSid *). More... | |
Public Member Functions | |
XrdOucSid (int numSid=256, bool mtproof=true, XrdOucSid *glblSid=0) | |
~XrdOucSid () | |
bool | Obtain (theSid *sidP) |
bool | Release (theSid *sidP) |
void | Reset () |
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.
Definition at line 45 of file XrdOucSid.hh.
union XrdOucSid::theSid |
The type to pass to Obtain(). Simply cast the char[2] to (theSid *).
Definition at line 53 of file XrdOucSid.hh.
Class Members | ||
---|---|---|
char | sidC[2] | |
short | sidS |
XrdOucSid::XrdOucSid | ( | int | numSid = 256 , |
bool | mtproof = true , |
||
XrdOucSid * | glblSid = 0 |
||
) |
Constructor
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. |
Definition at line 37 of file XrdOucSid.cc.
XrdOucSid::~XrdOucSid | ( | ) |
Destructor. Only this object is destroyed. The global object, if any, is not alteered in any way.
Definition at line 61 of file XrdOucSid.cc.
bool XrdOucSid::Obtain | ( | XrdOucSid::theSid * | sidP | ) |
Obtain a stream ID. When not needed use Release() to recycle them.
sidP | -> the place where the new stream ID is to be placed. |
Definition at line 70 of file XrdOucSid.cc.
References XrdSysMutex::Lock(), Obtain(), XrdProxy::sidP, and XrdSysMutex::UnLock().
Referenced by Obtain(), and XrdPssUrlInfo::setID().
bool XrdOucSid::Release | ( | XrdOucSid::theSid * | sidP | ) |
Release a stream ID using the stream ID value.
sidP | -> to the stream ID cast as a theSid pointer. |
Definition at line 115 of file XrdOucSid.cc.
References XrdSysMutex::Lock(), Release(), XrdProxy::sidP, and XrdSysMutex::UnLock().
Referenced by XrdPssUrlInfo::~XrdPssUrlInfo(), and Release().
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.
Definition at line 147 of file XrdOucSid.cc.
References XrdSysMutex::Lock(), and XrdSysMutex::UnLock().