Deleting objects in a PSpace

It's not practical to use a tracing garbage collector for all the persistent objects on disk in a given PSpace. Instead there are functions to permanently objects.


void AsyncPermanentlyDeleteSubTree(ptr<IPersistable> obj)

When it is known that an entire sub-tree has been (permanently) orphaned, this function should be called. The sub-tree will be asynchronously deleted in the background. The PSpace can be closed any number of times before deletion is complete, and asynchronous deletion will automatically continue each time the PSpace is opened again. RepresentsSubTree() must return true for the given object The calling thread must have opened a transaction with exclusive write access to this PSpace


void AsyncPermanentlyDeleteObject(ptr<IPersistable> obj)

As for AsyncPermanentlyDeleteSubTree except there is no pref trace


void SyncPermanentlyDeleteSubTree(ptr<IPersistable> obj)

Synchronously permanently delete a subtree of objects. The given subtree must already be persistent (i.e. each object has an associated oid). Just after calling this function every object in the subtree can be regarded as transient (and GetOid() on any of these objects will return a null oid). Furthermore, TryBindObjectGivenOid(oid) will now return null for that oid - even in the same PSpaceTxn. The transient tree of objects will still be wired up as before (i.e. the oids in the cref members will be have cleared, but the memory pointers will be bound as required). Calling this function causes all the objects in the subtree to be removed from the LSS (but only when the transaction is made durable). The calling thread must have opened a transaction with exclusive write access to this PSpace


void SyncPermanentlyDeleteObject(ptr<IPersistable> obj)

Synchronously permanently delete the given object. The given object must already be persistent (i.e. the object has an associated oid). Just after calling this function the given object can be regarded as transient (and GetOid() on the object will return a null oid). Furthermore, TryBindObjectGivenOid(oid) will now return null for that oid - even in the same PSpaceTxn. Calling this function causes the object to be removed from the LSS (but only when the transaction is made durable). The calling thread must have opened a transaction with exclusive write access to this PSpace

TODO: Actually after calling this function GetOid() still returns the original oid

Free functions

Given that it is possible to get the associated PSpace of a given IPersistable object we can have free functions corresponding to the above four PSpace methods.


$function+ void AsyncPermanentlyDeleteSubTree(ptr<IPersistable> obj)
{
    if (PSpace* pspace = GetAssociatedPSpace(obj))
    {
        AsyncPermanentlyDeleteSubTree(pspace, obj);
    }
}
$function+ void AsyncPermanentlyDeleteObject(ptr<IPersistable> obj)
{
    if (PSpace* pspace = GetAssociatedPSpace(obj))
    {
        AsyncPermanentlyDeleteObject(pspace, obj);
    }
}

$function+ void SyncPermanentlyDeleteSubTree(ptr<IPersistable> obj)
{
    if (PSpace* pspace = GetAssociatedPSpace(obj))
    {
        SyncPermanentlyDeleteSubTree(pspace, obj);
    }
}

$function+ void SyncPermanentlyDeleteObject(ptr<IPersistable> obj)
{
    if (PSpace* pspace = GetAssociatedPSpace(obj))
    {
        SyncPermanentlyDeleteObject(pspace, obj);
    }
}

void AsyncPermanentlyDeleteSubTree(ptr<IPersistable> obj)

If obj isn't null and it has an associated PSpace then this function calls AsyncPermanentlyDeleteSubTree(obj) on the associated PSpace, otherwise this function is a no-op.


void AsyncPermanentlyDeleteObject(ptr<IPersistable> obj)

If obj isn't null and it has an associated PSpace then this function calls AsyncPermanentlyDeleteObject(obj) on the associated PSpace, otherwise this function is a no-op.


void SyncPermanentlyDeleteSubTree(ptr<IPersistable> obj)

If obj isn't null and it has an associated PSpace then this function calls SyncPermanentlyDeleteSubTree(obj) on the associated PSpace, otherwise this function is a no-op.


void SyncPermanentlyDeleteObject(ptr<IPersistable> obj)

If obj isn't null and it has an associated PSpace then this function calls SyncPermanentlyDeleteObject(obj) on the associated PSpace, otherwise this function is a no-op.