IAsyncBindRequestHandler

IAsyncBindRequestHandler is implemented in order to handle requests to asynchronously bind to an object with given OID which currently doesn't exist in the PSpace. It is typically associated with replication of objects between processes, and may involve IPC messages that make requests for objects, cancel requests for objects and send the serialised state of objects. The cxPersistStore library supports this functionality by defining the appropriate interface and hook, but doesn't itself implement this functionality.

BeginAsyncBindRequest() and EndAsyncBindRequest() are paired for a given OID and define a period of time for which an asynchronous bind is pending.

The implementation of BeginAsyncBindRequest() returns true to mark the beginning of a period for which the request handler will try to bind asynchronously (say by requesting the object be sent from another process using IPC). EndRequestAsyncBind() marks the end of this period and may cause cancel messages to be sent over the wire.

BeginAsyncBindRequest() returns false to indicate that the request handler will not try to bind the OID. In that case PSpace::AsyncBind2() will return MAsyncBind with result==DoesNotExist and EndAsyncBindRequest() is not called.

EndAsyncBindRequest() may not be called if PSpace::SetAsyncBindRequestHandler() is used to remove the existing handler.

The implementor of IAsyncBindRequestHandler can invoke the following method of the PSpace with an exclusive lock on the CSpace to insert the result of an async bind:


MakeObjectPersistWithGivenOID(ptr<IPersistable> po, OID oid, bool trace);

The implementor of IAsyncBindRequestHandler may send an IPC request to multiple peers, and it's possible that multiple copies are independently created for a given OID. If there are multiple calls to MakeObjectPersistWithGivenOID() for the same OID then the last call dominates the previous calls.

There are no restrictions on when MakeObjectPersistWithGivenOID() may be called. For example, an object may be inserted into the PSpace using MakeObjectPersistWithGivenOID() even though no agent depends on it, and so BeginAsyncBindRequest() hasn't been invoked on the request handler. This allows ROD objects to be pushed over the wire (not pulled on demand) when that policy happens to be appropriate.


$interface+ IAsyncBindRequestHandler
{
    MAsyncBind BeginAsyncBindRequest(OID oid);
    void EndAsyncBindRequest(OID oid);
};


MAsyncBind BeginAsyncBindRequest(OID oid)

Always called with CSpace/PSpace set in TLS and an exclusive lock on the CSpace. The given OID is never null.


void EndAsyncBindRequest(OID oid)

Called when async binding of the given OID is no longer pending (meaning it either has bound or it has been determined that the object no longer exists).

Always called with CSpace/PSpace set in TLS and an exclusive lock on the CSpace. The given OID is never null.