![]() |
XRootD
|
#include <XrdSsiShMam.hh>
Public Types | |
enum | LockType { ROLock = 0 , RWLock = 1 } |
Public Member Functions | |
XrdSsiShMam (XrdSsiShMat::NewParms &parms) | |
~XrdSsiShMam () | |
bool | AddItem (void *newdata, void *olddata, const char *key, int hash, bool replace=false) |
bool | Attach (int tout, bool isrw=false) |
bool | Create (XrdSsiShMat::CRZParms &parms) |
bool | DelItem (void *data, const char *key, int hash) |
void | Detach () |
Detach the map from the shared memory. More... | |
bool | Enumerate (void *&jar) |
bool | Enumerate (void *&jar, char *&key, void *&val) |
bool | Export () |
bool | GetItem (void *data, const char *key, int hash) |
int | Info (const char *vname, char *buff=0, int blen=0) |
bool | Resize (XrdSsiShMat::CRZParms &parms) |
bool | Sync () |
bool | Sync (bool dosync, bool syncdo) |
bool | Sync (int syncqsz) |
![]() | |
XrdSsiShMat (NewParms &parms) | |
Constructor (arguments the same as for New()) More... | |
virtual | ~XrdSsiShMat () |
Destructor. Warning, your destructor should call your own Detach()! More... | |
Additional Inherited Members | |
![]() | |
static XrdSsiShMat * | New (NewParms &parms) |
![]() | |
int | shmHash |
char * | shmImpl |
char * | shmPath |
char * | shmType |
int | shmTypeSz |
Definition at line 37 of file XrdSsiShMam.hh.
XrdSsiShMam::XrdSsiShMam | ( | XrdSsiShMat::NewParms & | parms | ) |
Definition at line 218 of file XrdSsiShMam.cc.
|
inline |
Definition at line 70 of file XrdSsiShMam.hh.
References Detach().
|
virtual |
Add an item to the shared memory table.
newdata | Pointer to the data to be added. |
olddata | Pointer to the area where the replaced data, if any, is to be placed. |
key | The key associated with the data that is to be added. |
hash | The hash of the key that is to be used to lookup the key. If the value is zero, an internal hash is computed. |
replace | When true, if the key exists, the data associated with the key is replaced. When false, if the key exists, the addition fails with errno set to EEXIST. |
Implements XrdSsiShMat.
Definition at line 251 of file XrdSsiShMam.cc.
References Atomic_SET, ITEM_KEY, ITEM_VAL, ITEM_VOF, RWLock, SHMINFO, SHMOFFS, and XrdSsiShMat::shmTypeSz.
Referenced by Resize().
|
virtual |
Attach this object to the shared memory associated with this object at creation time (see New() method). The attach operation waits until the shared memory file is available. At that time, the file is memory mapped.
tout | The maximum number of seconds to wait for the shared memory file to become available. If tout is zero, then the file must be immediately available. If the value is negative then the attach waits as long as needed. When tout is reached the attach fails with errno set to ETIMEDOUT. |
isrw | When true the file is mapped to writable memory and allows updates to the table. If false, the shared memory is made read/only and may be significantly faster to access. |
Implements XrdSsiShMat.
Definition at line 350 of file XrdSsiShMam.cc.
References Atomic, fstat(), ROLock, RWLock, SHMADDR, XrdSsiShMat::shmHash, XrdSsiShMat::shmImpl, SHMINFO, XrdSsiShMat::shmPath, XrdSsiShMat::shmType, XrdSsiShMat::shmTypeSz, and stat().
|
virtual |
Implements XrdSsiShMat.
Definition at line 440 of file XrdSsiShMam.cc.
References ftruncate(), XrdSsiShMat::CRZParms::indexSz, XrdSsiShMat::CRZParms::maxKeys, XrdSsiShMat::CRZParms::maxKLen, XrdSsiShMat::CRZParms::mode, XrdSsiShMat::CRZParms::multW, XrdSys::PageSize, XrdSsiShMat::CRZParms::reUse, SHMADDR, XrdSsiShMat::shmHash, XrdSsiShMat::shmImpl, SHMINFO, XrdSsiShMat::shmPath, XrdSsiShMat::shmType, and XrdSsiShMat::shmTypeSz.
Referenced by Resize().
|
virtual |
Delete an item from the table.
data | Pointer to the area to receive the value of the deleted key. If the pointer is nil, then the key value is not returned. |
key | Pointer to the key of length <= MaxKLen. |
hash | The hash of the key that is to be used to lookup the key. If the value is zero, an internal hash is computed. |
Implements XrdSsiShMat.
Definition at line 558 of file XrdSsiShMam.cc.
References ITEM_VAL, RWLock, SHMINFO, SHMOFFS, and XrdSsiShMat::shmTypeSz.
|
virtual |
Detach the map from the shared memory.
Implements XrdSsiShMat.
Definition at line 618 of file XrdSsiShMam.cc.
References close.
Referenced by ~XrdSsiShMam().
|
virtual |
Terminate an active enumeration. An active enumeration is any enumeration where the previous form of Enumerate() did not return false. Terminating an active enumeration releases all of the enumeration resources allocated.
jar | The opaque cookie initialized by a previous call to Enumerate() requesting the next key-value pair. |
Implements XrdSsiShMat.
Definition at line 632 of file XrdSsiShMam.cc.
|
virtual |
Enumerate the keys and assocaited values.
jar | An opaque cookie that tracks progress. It should be initialized to zero and otherwise not touched. The same jar must be used for all successive calls. The jar is deleted when false is returned (also see the next Enumerate method). |
key | The pointer variable where the location of the key is returned upon success. |
val | The pointer variable where the location f the key values is to be returned upon success. |
Implements XrdSsiShMat.
Definition at line 644 of file XrdSsiShMam.cc.
References ITEM_KEY, ITEM_VAL, pread(), ROLock, and SHMINFO.
|
virtual |
Export a newly created table (i.e. see Create()).
Implements XrdSsiShMat.
Definition at line 714 of file XrdSsiShMam.cc.
References RWLock.
|
virtual |
Get an item from the table.
data | Pointer to an area to receive the value associated with key. If the pointer is nil, then the key value is not returned. |
key | Pointer to the key of length <= MaxKLen. |
hash | The hash of the key that is to be used to lookup the key. If the value is zero, an internal hash is computed. |
Implements XrdSsiShMat.
Definition at line 854 of file XrdSsiShMam.cc.
References ITEM_VAL, ROLock, SHMINFO, and XrdSsiShMat::shmTypeSz.
|
virtual |
Return information about the table.
vname | Pointer to the variable name whose value is wanted. A particular implementation may not support all variable and may support variables not listed here. These are for the default implementation unless otherwise noted. They are: hash - name of hash being used. impl - The table implementation being used. indexsz - Number of index entries indexused - Number of index entries in use keys - Number of keys in the bale. keys/indexused is the hash table collision factor keysfree - Number of keys that can still be added maxkeylen - Longest allowed key multw - If table supports multiple writers, else 0 reuse - If table allows object reuse, else 0 type - Name of the data type in the table. typesz - The number of bytes in the table's data type |
buff | - Pointer to the buffer to receive text values. Variables that return text are: hash, impl, and type. A buffer must be supplied in any of these variables are requested. If buff is nill or too small a -1 is returned with errno set to EMSGSIZE. |
blen | The length of the buffer. |
Implements XrdSsiShMat.
Definition at line 961 of file XrdSsiShMam.cc.
References Atomic_IMP, ROLock, and SHMINFO.
|
virtual |
Resize a shared memory segment and associated file specified at object instantiation (see New() method). Resizing is implementation specific but may involve creating a new table and exporting it.
parms | Resize parameters. See the CRZParms struct for details. For resize, zero values or unspecified flags use the existing table values. |
Implements XrdSsiShMat.
Definition at line 1087 of file XrdSsiShMam.cc.
References AddItem(), Create(), XrdSsiShMat::NewParms::hashID, XrdSsiShMat::NewParms::impl, XrdSsiShMat::CRZParms::indexSz, ITEM_KEY, ITEM_VAL, XrdSsiShMat::CRZParms::maxKeys, XrdSsiShMat::CRZParms::maxKLen, XrdSsiShMat::CRZParms::mode, XrdSsiShMat::CRZParms::multW, XrdSsiShMat::NewParms::path, XrdSsiShMat::CRZParms::reUse, RWLock, SHMADDR, XrdSsiShMat::shmHash, XrdSsiShMat::shmImpl, SHMINFO, XrdSsiShMat::shmPath, XrdSsiShMat::shmType, XrdSsiShMat::shmTypeSz, XrdSsiShMat::NewParms::typeID, and XrdSsiShMat::NewParms::typeSz.
|
virtual |
Synchronize all modified pages to the associated backing file.
Implements XrdSsiShMat.
Definition at line 1274 of file XrdSsiShMam.cc.
References RWLock.
|
virtual |
Turn memry synchronization on or off.
dosync | When true, modified table pages are written back to the backing file. The synchronous or async nature of the write is controlled by the second parameter. When false, memory-file synchronization is turned off (initial setting). |
syncdo | When true, synchronization is done in the forground. That is, a call triggering a sync will not return until complete. When false, synchronization is done in the background. |
Implements XrdSsiShMat.
Definition at line 1320 of file XrdSsiShMam.cc.
References RWLock.
|
virtual |
Set the sync defer queue size.
synqsz | The maximum number of modified pages before flushing. |
Implements XrdSsiShMat.
Definition at line 1298 of file XrdSsiShMam.cc.
References RWLock.