Implementing a Resource Dispenser
The following steps outline a general procedure for implementing a resource dispenser:
-
Decide on RESTYPID format which categorizes how your resources differ from each other.
-
Use the
Mtxdm.h
and mtxdm.lib
header file and library, respectively.
-
Build a DLL which implements IDispenserDriver and the API you expose to applications.
-
In the startup (DllMain or first call to the dispenser API), call GetDispenserManager. This returns a pointer to the DispMan's IDispenserManager.
-
Call RegisterDispenser, passing a pointer to your implementation of IDispenserDriver. This will cause DispMan to create a holder (pooling manager) for your resource dispenser and then return the pointer to your IHolder.
-
Store this pointer in order to call AllocResource and FreeResource.
-
You can now (in response to calls to your API)make calls to AllocResource and FreeResource. AllocResource will initially respond by calling back to your CreateResource method, but later AllocResource calls will be serviced from the growing pool of resources.
For more information, see the TxFileDisp sample.