![]() |
XRootD
|
#include <XrdSsiShMap.hh>
Public Member Functions | |
ShMap (const char *typeName, ShMap_Hash_t hFunc=0, const char *implName=0) | |
~ShMap () | |
Destructor. More... | |
bool | Add (const char *key, T &val) |
bool | Attach (const char *path, ShMap_Access access, int tmo=-1) |
bool | Create (const char *path, ShMap_Parms &parms) |
bool | Del (const char *key, T *valP=0) |
void | Detach () |
Detach the map from the shared memory. More... | |
bool | Enumerate (void *&jar) |
bool | Enumerate (void *&jar, char *&key, T *&val) |
bool | Exists (const char *key) |
bool | Export () |
bool | Get (const char *key, T &val) |
int | Info (const char *vname, char *buff=0, int blen=0) |
bool | Rep (const char *key, T &val, T *valP=0) |
bool | Resize (ShMap_Parms *parms=0) |
bool | Sync (SyncOpt dosync, int syncqsz=256) |
Definition at line 125 of file XrdSsiShMap.hh.
|
inline |
Constructor. First allocate a ShMap object of appropriate type. Then call Attach() to attach it to a shared memory segment before calling any other method in this class. When through either delete the object.
typeName | - A text name of the type in the map. Attach() makes sure that the map has this type. Specify text < 64 characters. Example: XrdSsi::ShMap<int> myMap("int"); |
hFunc | - An optional pointer to to the hash computation function to be used. If not specified, a crc32 hash is used. |
implName | - A text name of the map implementation desired. Zero uses the default implementation. Currently only the default implementation is available. |
Definition at line 403 of file XrdSsiShMap.hh.
|
inline |
Destructor.
Definition at line 412 of file XrdSsiShMap.hh.
References XrdSsi::ShMap< T >::Detach().
bool XrdSsi::ShMap< T >::Add | ( | const char * | key, |
T & | val | ||
) |
Add an item to the map (see the Rep() method for key/data replacement).
key | pointer to the key of length <= MaxKeySize. |
val | The associated data to be added to the map. |
Definition at line 37 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Attach | ( | const char * | path, |
XrdSsi::ShMap_Access | access, | ||
int | tmo = -1 |
||
) |
Attach an existing shared memory map.
path | Pointer to the file that is or will represent the map. |
access | How to attach the map. Specify one of the following: ReadOnly - Attach the map strictly for reading. ReadWrite - Attach the map in read/write mode. New and |
tmo | How many seconds to wait for the map to appear. It is possible that a new map may have not yet been exported, so attach will wait for the map to become visible. Specify, <0 - wait forever. =0 - do not wait at all. >0 - wait the specified number seconds and then timeout. |
Definition at line 57 of file XrdSsiShMap.icc.
References access(), XrdSsiShMat::NewParms::hashID, XrdSsiShMat::NewParms::impl, XrdSsiShMat::New(), XrdSsiShMat::NewParms::path, XrdSsi::ReadOnly, XrdSsiShMat::NewParms::typeID, and XrdSsiShMat::NewParms::typeSz.
bool XrdSsi::ShMap< T >::Create | ( | const char * | path, |
XrdSsi::ShMap_Parms & | parms | ||
) |
Create a new r/w shared memory map possibly replacing an existing one upon export. New maps must be exported to become visible (see Export()).
This method first creates a temporary map visible only to the creator. This allows you to fill the map as needed with minimal overhead. Once this is done, call Export() to make the new map visible, possibly replacing an any existing version of a map with the same name.
path | Pointer to the file that is or will represent the map. |
parms | Reference to the parameters. See the ShMap_Parms struct for for details and constructor defaults. Below is a detailed explanation of the available options: |
MultW - The map has multiple processes writing to it. All writers must obtain an exclusive file lock before updating the map. No file locks are needed ReUse - Allow reuse of storage in the map. Use this if the map has many inserts/deletes. If set, r/o access will always lock the map file before looking at it. Otherwise, there is no need for file locks as no item is ever reused. ReUse is good when there are few key add/delete cycles.
Definition at line 106 of file XrdSsiShMap.icc.
References XrdSsiShMat::NewParms::hashID, XrdSsiShMat::NewParms::impl, XrdSsi::ShMap_Parms::indexSize, XrdSsiShMat::CRZParms::indexSz, XrdSsi::ShMap_Parms::maxKeyLen, XrdSsi::ShMap_Parms::maxKeys, XrdSsiShMat::CRZParms::maxKeys, XrdSsiShMat::CRZParms::maxKLen, XrdSsi::ShMap_Parms::mode, XrdSsiShMat::CRZParms::mode, XrdSsi::ShMap_Parms::MultW, XrdSsiShMat::CRZParms::multW, XrdSsiShMat::New(), XrdSsi::ShMap_Parms::options, XrdSsiShMat::NewParms::path, XrdSsi::ShMap_Parms::ReUse, XrdSsiShMat::CRZParms::reUse, XrdSsiShMat::NewParms::typeID, and XrdSsiShMat::NewParms::typeSz.
bool XrdSsi::ShMap< T >::Del | ( | const char * | key, |
T * | valP = 0 |
||
) |
Delete an item from the map.
key | Pointer to the key of length <= MaxKeySize. |
valP | Pointer to the area to receive the value of the deleted key. If the pointer is nil, then the key value is not returned. |
Definition at line 157 of file XrdSsiShMap.icc.
void XrdSsi::ShMap< T >::Detach |
Detach the map from the shared memory.
Definition at line 177 of file XrdSsiShMap.icc.
Referenced by XrdSsi::ShMap< T >::~ShMap().
bool XrdSsi::ShMap< T >::Enumerate | ( | void *& | jar | ) |
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() whose enumeration is to be terminated. |
Definition at line 203 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Enumerate | ( | void *& | jar, |
char *& | key, | ||
T *& | val | ||
) |
Enumerate the keys and associated 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. The key is overwritten on the next call to Enumerate(); so copy it if you want to keep it. |
val | The pointer variable where the location of the key value is to be returned upon success. The value is overwritten on the next call to Enumerate(). Copy it if you want to keep it. |
Definition at line 189 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Exists | ( | const char * | key | ) |
Determine whether or not a key exists in the map.
key | Pointer to the key of length <= MaxKeySize. |
Definition at line 219 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Export |
Export a newly created map (i.e. one that was attached using ShMop_New).
Definition at line 239 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Get | ( | const char * | key, |
T & | val | ||
) |
Find a key in the map and return its value.
key | Pointer to the key of length <= MaxKeySize. |
val | Reference to the area to receive the value of the found key. |
Definition at line 255 of file XrdSsiShMap.icc.
int XrdSsi::ShMap< T >::Info | ( | const char * | vname, |
char * | buff = 0 , |
||
int | blen = 0 |
||
) |
Return information about the map.
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 map. keys/indexused is the hash table collision factor keysfree - Number of keys that can still be added maxkeylen - Longest allowed key multw - If 1 map supports multiple writers, else 0 reuse - If 1 map allows object reuse, else 0 type - Name of the data type in the table. typesz - The number of bytes in the map'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. |
Definition at line 275 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Rep | ( | const char * | key, |
T & | val, | ||
T * | valP = 0 |
||
) |
Add to or replace an item in the map.
key | Pointer to the key of length <= MaxKeySize. |
val | The associated data to be added to or replaced in the map. |
valP | Pointer to the area to receive the value of a replaced key. If the pointer is nil, then the key value is not returned. |
Definition at line 291 of file XrdSsiShMap.icc.
bool XrdSsi::ShMap< T >::Resize | ( | XrdSsi::ShMap_Parms * | parms = 0 | ) |
Resize or change options on an existing map attached in read/write mode. The map must have been exported.
parms | Pointer to the parameters. See the ShMap_Parms struct for for details and constructor defaults. A zero value in the parameter list uses the existing map value allowing you to selectively change the map sizing and options. If a nil pointer is passed, the map is simply compressed. |
Definition at line 311 of file XrdSsiShMap.icc.
References XrdSsi::ShMap_Parms::ForResize, XrdSsi::ShMap_Parms::indexSize, XrdSsiShMat::CRZParms::indexSz, XrdSsi::ShMap_Parms::maxKeyLen, XrdSsi::ShMap_Parms::maxKeys, XrdSsiShMat::CRZParms::maxKeys, XrdSsiShMat::CRZParms::maxKLen, XrdSsi::ShMap_Parms::mode, XrdSsiShMat::CRZParms::mode, XrdSsi::ShMap_Parms::MultW, XrdSsiShMat::CRZParms::multW, XrdSsi::ShMap_Parms::options, XrdSsi::ShMap_Parms::ReUse, and XrdSsiShMat::CRZParms::reUse.
bool XrdSsi::ShMap< T >::Sync | ( | XrdSsi::SyncOpt | dosync, |
int | syncqsz = 256 |
||
) |
Specify how the memory map is synchronized with its backing file. If sync is already enabled, calling this method writes back any modified pages before effecting any requested changes.
dosync | Controls how synchronization is done (see SyncOpt enum): SyncOff - Turn synchronization off (initial setting). SyncOn - Turn synchronization on; pages are written in the background (i.e. asynchronously). SyncAll - Turn synchronization on; pages are written in the foreground(i.e. synchronously). SyncNow - Write back any queued pages but otherwise keep all other settings the same. SyncQSz - Set the queue size specified in the second argument. This number of modified pages are queued before being written back to disk. No other setting in effect are altered. |
syncqsz | Specifies the defer-writeback queue size. This argument is ignored unless SyncQSz has been specified (see above). |
Definition at line 345 of file XrdSsiShMap.icc.
References XrdSsi::SyncAll, XrdSsi::SyncNow, XrdSsi::SyncOff, XrdSsi::SyncOn, and XrdSsi::SyncQSz.