Resource Dispenser Resource Allocation Process

Each time a resource dispenser allocates a resource from its holder, the following occurs:

  1. The resource dispenser declares a resource type identifier (RESTYPID), which describes the type of resource required.

  2. The resource dispenser calls the holder's IHolder::AllocResource method, passing this RESTYPID.

  3. The holder generates a candidate list from the available resources. Candidates are resources that are either not enlisted in a transaction or already enlisted in the calling object's transaction.

  4. These candidates are individually passed to the IDispenserDriver::RateResource method where they are rated (on a scale of 0 to 100) by how well the candidate resource matches the desired RESTYPID.

  5. The holder chooses the resource that the resource dispenser rates as highest.

  6. The resource dispenser can terminate the rating loop early by assigning the candidate a resource rating of 100 (a perfect fit). A rating of 100 would normally be reserved for candidate resources that are already properly enlisted, unless the resource dispenser concludes that enlistment is an inexpensive operation. If all candidate resources (if any) are rated 0 (unusable), a new resource is created by calling IDispenserDriver::CreateResource.

  7. If the resource chosen previously is not already enlisted in the calling object's transaction, the resource dispenser's IDispenserDriver::EnlistResource method is called.

  8. The AllocResource method call returns to the resource dispenser with the enlisted resource.

COM+ Resource Dispenser Concepts

Enlisting a Resource in a Transaction

Tracking Non-Allocated Resources