Platform SDK: Transaction Server

IHolder::AllocResource

Allocates a resource from the inventory.

HRESULT IHolder::AllocResource (
RESTYPID
ResTypId,
RESID *
pResId);

Parameters

ResTypId [in]
The type of resource to be allocated.

pResId [out]
Points to the location where the handle of the resource allocated is returned.

Return Values

S_OK
Success.

E_INVALIDARG
ResTypId is NULL or "", or the resource dispenser's CreateResource generated empty or duplicate RESID.

E_FAIL
Failure. *pResId has not been set. Likely cause is that the caller's transaction is aborting.

Comments

DispMan takes the following steps to locate a resource:

  1. Searches the pool for a free resource of this RESTYPID, which is already enlisted in the caller's current transaction.
  2. Searches the pool for a free unenlisted resource of this RESTYPID, and then enlists it in the caller’s current transaction.
  3. Creates the resource by calling back to the resource dispenser's IDispenserDriver::CreateResource, and then enlisting it.

If the caller does not have a current transaction, then the enlistment is skipped. Or if the resource dispenser rejects the enlistment (meaning the resource is not transaction capable), then the enlistment is skipped.