My Project
|
#include <rpl_gtid.h>
Classes | |
struct | Node |
Node pointed to by both the hash and the array. | |
Public Member Functions | |
Sid_map (Checkable_rwlock *sid_lock) | |
~Sid_map () | |
Destroy this Sid_map. | |
rpl_sidno | add_sid (const rpl_sid &sid) |
rpl_sidno | sid_to_sidno (const rpl_sid &sid) const |
const rpl_sid & | sidno_to_sid (rpl_sidno sidno) const |
rpl_sidno | get_sorted_sidno (rpl_sidno n) const |
rpl_sidno | get_max_sidno () const |
Represents a bidirectional map between SID and SIDNO.
SIDNOs are always numbers greater or equal to 1.
This data structure OPTIONALLY knows of a read-write lock that protects the number of SIDNOs. The lock is provided by the invoker of the constructor and it is generally the caller's responsibility to acquire the read lock. If the lock is not NULL, access methods assert that the caller already holds the read (or write) lock. If the lock is not NULL and a method of this class grows the number of SIDNOs, then the method temporarily upgrades this lock to a write lock and then degrades it to a read lock again; there will be a short period when the lock is not held at all.
Sid_map::Sid_map | ( | Checkable_rwlock * | sid_lock | ) |
Create this Sid_map.
sid_lock | Read-write lock that protects updates to the number of SIDNOs. |
rpl_sidno Sid_map::add_sid | ( | const rpl_sid & | sid | ) |
Add the given SID to this map if it does not already exist.
The caller must hold the read lock or write lock on sid_lock before invoking this function. If the SID does not exist in this map, it will release the read lock, take a write lock, update the map, release the write lock, and take the read lock again.
sid | The SID. |
SIDNO | The SIDNO for the SID (a new SIDNO if the SID did not exist, an existing if it did exist). |
negative | Error. This function calls my_error. |
rpl_sidno Sid_map::get_max_sidno | ( | ) | const [inline] |
Return the biggest sidno in this Sid_map.
The caller must hold the read or write lock on sid_lock before invoking this function.
rpl_sidno Sid_map::get_sorted_sidno | ( | rpl_sidno | n | ) | const [inline] |
Return the n'th smallest sidno, in the order of the SID's UUID.
The caller must hold the read or write lock on sid_lock before invoking this function.
n | A number in the interval [0, get_max_sidno()-1], inclusively. |
rpl_sidno Sid_map::sid_to_sidno | ( | const rpl_sid & | sid | ) | const [inline] |
Get the SIDNO for a given SID
The caller must hold the read lock on sid_lock before invoking this function.
sid | The SID. |
SIDNO | if the given SID exists in this map. |
0 | if the given SID does not exist in this map. |
const rpl_sid& Sid_map::sidno_to_sid | ( | rpl_sidno | sidno | ) | const [inline] |
Get the SID for a given SIDNO.
An assertion is raised if the caller does not hold a lock on sid_lock, or if the SIDNO is not valid.
sidno | The SIDNO. |