41 Resident Object Table (ROT)
The Resident Object Table (ROT) records the set of IPersistable objects for a single PSpace that have been allocated an OID and are currently resident in memory.
$adt PSpace
{
// The Resident Object Table (ROT) keeps track of all the persistable objects currently
// resident in memory
ROT rot_;
};
The ROT supports both synchronous and asynchronous modes of access. Synchronous means that the calling thread blocks on I/O as required until the object is loaded from disk. Asychronous means that the calling thread avoids blocking on I/O, and can return null because the object is not resident in memory.
An async bind can cause an independent node of the DGS to be created and the read barrier is invoked in the independent node allowing dependency edges to form. A task is posted to a thread pool to load the object from the LSS. Once the object is loaded the independent node is evicted (because it is no longer needed). This invalidates the dependents.
Public interface
class ROT
{
public:
////////////// Public methods called without a lock on the PSpace
ROT(PSpace& pspace);
void Close();
////////////// Public methods called with a lock on the PSpace
ptr<IPersistable> FindResidentObject(OID oid) const;
ptr<IPersistable> FindOrLoadResidentObject(OID oid);
bool AddResidentObject(OID oid, ptr<IPersistable> po);
void RemoveResidentObject(OID oid);
void TransferResidentObjects(ROT& src);
MAsyncBind AsyncBind2(OID oid);
ptr<IPersistable> AsyncBind(OID oid) { return AsyncBind2(oid).po; }
};
void Close()
Called when the PSpace is being closed. Blocks until all DGIndepNodeForAsyncPref which were created by the ROT have deleted themselves, implying all asynchronous tasks have completed.
ptr<IPersistable> FindResidentObject(OID oid) const
Find the object with given OID, or returns null if not currently resident in memory This function never blocks on I/O (either directly or indirectly).
Must only be called by a thread that has a locked the PSpace.
Currently called :
- in debug builds from PSpace::MakeObjectPersist() with a CSpace lock in order to ensure that a freshly allocated oid doesn't already exist in the ROT.
- from PSpace::BindObjectIfMemoryResident(OID oid) which must be called with a CSpace lock. prefbase::GetInMemory() calls BindObjectIfMemoryResident().
ptr<IPersistable> FindOrLoadResidentObject(OID oid)
Bind to the object with given oid - either to an object that is already resident in memory, or else load the object from disk. Blocks on I/O as required. Returns null if no object with the given oid was found in the LSS. May throw exceptions.
Must only be called by a thread that has locked the PSpace.
Currently called :
- From PSpace::BindObject(OID oid) which asserts there is a CSpace lock
- From PSpace::TryBindObject(OID oid) which asserts there is a CSpace lock
bool AddResidentObject(OID oid, ptr<IPersistable> po)
Called by PSpace::MakeObjectPersistWithGivenOID() to directly add new entries in the ROT as objects becomes persistent reachable for the first time.
Must only be called by a thread that has a locked the PSpace.
This function can be called when an async load for the given oid is in progress. In that case the async load is aborted.
If there is already an object with the given OID referenced by the ROT, then no change to the ROT is made and this function returns false.
void RemoveResidentObject(OID oid)
Called by the CSpace GC when it has an exclusive lock on the PSpace and has decided to evict the object with the given OID.
It is not permissible to call this function for an object that is not already resident in memory.
void TransferResidentObjects(ROT& src)
Transfer all entries from src into this ROT
MAsyncBind AsyncBind2(OID oid)
Implementation
See ROT source.