Writing the parent implementation


The implementation for a parent dispatcher handles:

    This involves identifying the object type and the child dispatcher that corresponds to it, allocating storage space and instantiating the dispatcher, performing an Add on the directory to insert the new dispatcher and get a child ID, and streaming the child ID into the reply.
    When a request comes in that includes a child ID, the implementation performs a Lookup to find the corresponding child dispatcher and either forwards the request to that dispatcher or returns an exception (if generated by the Lookup) to the child caller.
    When a dispatcher is no longer needed (based on the criteria you define), the implementation performs a Remove operation on the directory, then deletes the child dispatcher pointer returned by Remove.
Aside from these functions, the parent dispatcher implementation class usually handles little else specific to the request type. The child dispatcher and its corresponding implementation class take care of the remote request.

Multithread safety

While MRemoteDispatcher is not multithread-safe, TDispatcherChildDirectory is designed so that you can use it in a multithread-safe manner. When you use child objects with multiple threads, you must ensure that only one thread uses a particular child at a time.

To enforce this behavior, preface the code that uses a child with a call to TDispatcherChildDirectory::Use. End the code accessing that child with a call to TDispatcherChildDirectory::DoneWith.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker