Platform SDK: Transaction Server |
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
Objects that support the IObjectControl interface can participate in object recycling and pooling, which can increase the efficiency of activation and deactivation. After MTS calls the Deactivate method, it calls the CanBePooled method, allowing the object to be pooled for reuse. If the object returns TRUE, the object is added to the object pool. Objects that return FALSE or that do notsupport the IObjectControl interface are destroyed.
On activation, MTS uses an object from the pool if one is available. Only if the pool is empty will it use the component's class factory to create a new object.
Components that support object pooling must ensure that an object activated using an object from the pool is indistinguishable to the client from an object that is activated by creating a new object. Component developers must provide the appropriate code in the Activate and Deactivate method implementations to ensure this behavior.
The following table summarizes MTS run-time actions for client call processing.
IObjectControl implemented by component | ||
No | Yes | |
Step 1
Activate the object if needed (just-in-time activation). |
Use the component class factory to create an object. |
Allocate an object from the pool. If pooling is not supported or the pool is empty, then use the component class factory to create an object. |
Call the object's Activate method. | ||
Step 2
Execute the call. |
Call the object method. |
Call the object method. |
Step 3
Deactivate the object if requested (SetComplete or SetAbort called before return). |
Call object's Deactivate method |
|
Release the last reference held by the MTS run-time environment. | If the system supports pooling, then call CanBePooled. If it returns TRUE, then add the object to the pool. Otherwise, release the last reference held by the MTS run-time environment. |
Important Object pooling and recycling is not available in this release. MTS calls CanBePooled as described here, but no pooling takes place. This forward-compatibility encourages developers to use CanBePooled in their applications now in order to benefit from a future release without having to modify their applications later.