previous chapter contents page top page next chapter


FailsafeSemaphore

March 15, 1996

inherits from Semaphore;

Class Description

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.

Programming information

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.

Methods defined by class FailsafeSemaphore

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.

Fields defined by class FailsafeSemaphore

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

Method Descriptions

ReleaseFailsafe

class operation ReleaseFailsafe(actor: Actor)
Call: rarely
Override: never

Call ReleaseFailsafe to release any semaphores accessed by the given actor.

Install

overrides Install
Call: rarely
Override: sometimes

Class FailsafeSemaphore overrides Install to set up the indexical iFailsafeSemaphores when the semaphore is installed.

Init

overrides Init
Call: rarely
Override: sometimes

Class FailsafeSemaphore overrides Init to add the given semaphore to the indexical list of fail-safe semaphores.

Finalize

overrides Finalize
Call: rarely
Override: sometimes

Class FailsafeSemaphore overrides Finalize to remove the given semaphore from the indexical list of fail-safe semaphores.

Access

overrides Access
Call: rarely
Override: sometimes

Class FailsafeSemaphore overrides Access to set up the given semaphore's actor field when the semaphore is accessed.

Release

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.