Acquire lock on a named Resource
- Summary
- Acquire a lock on a named resource.
- Description
- This task acquires a lock on any named resource. If the named resource is free, meaning no other task holds a lock on it, then the acquisition of the resource succeeds and the task completes successfully. If another task holds a lock on the named resource, then the calling task is suspended until the other task releases the lock. Re-entrant acquisition is permitted and is always successful. A lock can be acquired by a sub-task within a compound task. If the lock is already held by the compound task (or its parent workflow, or a parent's parent), the acquisition is considered re-entrant and always succeeds. For example: Workflow WF-A acquires a lock L1 and spawns a Compound Task CT1. If a sub-task in CT1 tries to acquire L1, then the acquisition succeeds. Similarly, suppose workflow WF-B acquires a lock L2 and spawns CT2, which in turn spawns CT3. If a sub-task in CT3 tries to acquire L2, it will succeed because WF-B is an (indirect) parent of CT2. A workflow should relinquish the lock on the resource (using the Release Resource Lock task) as soon as it is done using the resource. Behavior during Rollback of an SR When a workflow is rolled back, the tasks are executed in reverse order of normal execution. When a workflow containing an AcquireLock followed by a ReleaseLock task is subjected to Rollback, the roles of AcquireLock and ReleaseLock are reversed. For example, consider this workflow: AcquireLock(R1) -> Task1 -> Task2 -> ReleaseLock(R1) In this example, AcquireLock(R1) acquires lock on resource R1 and ReleaseLock(R1) relinquishes the lock on R1. As part of a rollback, the ReleaseLock(R1) task is executed first. But since the intent is ensure safe access to resouce R1, this ReleaseLock behaves like an AcquireLock(R1) task and acquires the lock on R1. Subsequently, when the AcquireLock(R1) task is invoked it executes the ReleaseLock(R1) operation, relinquishing the lock on resource R1.
- Inputs
-
Input Description Mappable To Type Mandatory Resource name Name of resource that must be locked gen_text_input Y - Outputs
-
Output Description Type ResourceName Name of the Resource that was acquired for exclusive access gen_text_input