inherits from Semaphore;
If an actor has access to a semaphore when it throws an exception, a deadlock can result, which can cause Magic Cap to appear to stop. To avoid this problem, you can use a semaphore of class FailsafeSemaphore instead of a standard semaphore. If an actor has access to a fail-safe semaphore and is destroyed, Magic Cap releases the fail-safe semaphore.
Instantiate: sometimes Subclass: rarely Call its methods: rarely
You might create an object of this class if you want to have a semaphore associated with an actor that might be destroyed while the semaphore is accessed.
Class FailsafeSemaphore defines the following methods:
| Method | Description |
|---|---|
ReleaseFailsafe |
Release semaphores accessed by the given actor. |
| Install | Overridden to set up list of fail-safe semaphores. |
| Init | Overridden to add responder to list of fail-safe semaphores. |
| Finalize | Overridden to remove responder from list of fail-safe semaphores. |
| Access | Overridden to set up responder's actor field. |
| Release | Overridden to clear responder's actor field and run next actor. |
Class FailsafeSemaphore defines the following fields:
| Field | Type | Description |
|---|---|---|
| Inherited from class AbstractList | ||
| length | Unsigned | Length of a list element |
| Inherited from class Semaphore | ||
| releaseCount | Signed | Used by Magic Cap to maintain number of releases |
| Defined by class FailsafeSemaphore | ||
| actor | Actor | Actor with access to this semaphore |
class operation ReleaseFailsafe(actor: Actor) Call: rarely Override: never
Call ReleaseFailsafe to release any semaphores accessed by the given actor.
overrides Install Call: rarely Override: sometimes
Class FailsafeSemaphore overrides Install to set up the indexical iFailsafeSemaphores when the semaphore is installed.
overrides Init Call: rarely Override: sometimes
Class FailsafeSemaphore overrides Init to add the given semaphore to the indexical list of fail-safe semaphores.
overrides Finalize Call: rarely Override: sometimes
Class FailsafeSemaphore overrides Finalize to remove the given semaphore from the indexical list of fail-safe semaphores.
overrides Access Call: rarely Override: sometimes
Class FailsafeSemaphore overrides Access to set up the given semaphore's actor field when the semaphore is accessed.
overrides Release Call: rarely Override: sometimes
Class FailsafeSemaphore overrides Release to set the given semaphore's actor field to nilObject when the semaphore is accessed and to avoid deadlock by calling RunNext.