Implementing a Resource Dispenser

The following steps outline a general procedure for implementing a resource dispenser:

  1. Decide on RESTYPID format which categorizes how your resources differ from each other.
  2. Use the Mtxdm.h and mtxdm.lib header file and library, respectively.
  3. Build a DLL which implements IDispenserDriver and the API you expose to applications.
  4. In the startup (DllMain or first call to the dispenser API), call GetDispenserManager. This returns a pointer to the DispMan's IDispenserManager.
  5. 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.
  6. Store this pointer in order to call AllocResource and FreeResource.
  7. 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.