pub fn pre_map_pending_uses(
pool: &Arc<ResourcePool>,
tree: &SceneTree,
phases: &HashMap<String, WorkloadPhase>,
default_driver: &str,
merged_params: &HashMap<String, String>,
) -> Result<(), String>Expand description
Walk the freshly-pre-mapped scenario tree and seed the
pool’s pending_uses counter for every phase that will
attach a pool-shareable adapter. Called once at session
bootstrap, after [crate::executor::pre_map_tree] returns
and before the executor begins running any phase.
For each phase node:
- Determine the adapter name —
phase.adapteroverride (when the phase declares one) wins over the session-leveldefault_driver. - Resolve the driver name without instantiating
anything (
resolve_driver_name). - Look up the matching
SharedDriverRegistration. If none registered, the phase rides the legacyPerPhasepath — its key is per-phase-unique, so pre-map contributes zero to any sharedpending_usesand the legacy close-on-detach path handles teardown. - Compute the resource key from the session’s
merged_paramsvia the registration’s pureresource_keyfunction.resource_keyfailures are hard errors at session bootstrap — surfacing the same misconfiguration thatattach_shared_adapterwould have hit at runtime, just earlier and in one place. - Increment the per-key
pending_usescounter viaResourcePool::declare_pending_use.
This is a pure read of the scenario tree + phase params;
no adapters are instantiated. The walker can run before
pool.shutdown() would otherwise be a no-op — and must
run before the first phase, since pending counts are
the close trigger that releases shared resources promptly
when their last user finishes.