VoiceCleanup.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Doug Terry, June 26, 1986 2:19:03 pm PDT
VoiceCleanup:
CEDAR
DEFINITIONS =
BEGIN
STREAM: TYPE ~ IO.STREAM;
ROPE: TYPE ~ Rope.ROPE;
We use the following definitions of "garbage":
— A tune is garbage if it is not a component of any voice ropes.
— A voice rope is garbage if no client has an interest in that voice rope.
— An interest is garbage if it is no longer needed according to a class-specific algorithm.
These working definitions assume that the voice rope system is the only client of the voice storage server.
Garbage collection takes place at all three levels. A single collector exists for tunes, and one suffices for voice ropes. The Voice Rope Collector refuses to collect voice ropes that are too young in order to prevent it from collecting a newly created voice rope before a client has the opportunity to express an interest in it. We may need the same assurances at the tune level. Different garbage collectors are used to collect outdated interests of different classes since the definition of what constitutes garbage depends on the class of an interest.
All of the following collection routines take an optional IO.STREAM as a parameter. This is used to write out information about the voice being collected.
CollectTunes:
PROC [dbName:
ROPE ←
NIL, reports:
STREAM ←
NIL]
RETURNS [];
The Tune Collector enumerates the complete set of TuneIDs and calls CollectTune for each one. CollectTune[tuneID] queries the VoiceRope database to determine if any voice ropes make use of the tune. If not, then the tune is deleted.
CollectVoiceRopes:
PROC [dbName:
ROPE ←
NIL, reports:
STREAM ←
NIL]
RETURNS [];
The Voice Rope Collector enumerates the VoiceRope database and calls CollectVoiceRope for each entry. CollectVoiceRope[vr] queries the VoiceInterest database to determine if an interest exists in the voice rope. If not, and the voice rope is older than some period of time, then the entry is deleted from the VoiceRope database. In addition, an aggressive implementation calls CollectTune for each tune component of the voice rope.
InterestInfo: TYPE ~ VoiceRopeDB.InterestInfo;
IsGarbageProc: TYPE ~ PROC[interest: InterestInfo] RETURNS [BOOLEAN ← FALSE];
RegisterClass:
PROC [class:
ROPE, proc: IsGarbageProc]
RETURNS [];
Registers an IsGarbageProc to be used when garbage collecting interests of the given class.
CollectInterests:
PROC [dbName:
ROPE ←
NIL, class:
ROPE ←
NIL, reports:
STREAM ←
NIL]
RETURNS [];
The Voice Interest Collector enumerates all entries of the specified class in the VoiceInterest database and calls the registered IsGarbageProc for each one. If this call returns TRUE, then the entry is deleted from the VoiceInterest database. In addition, an aggressive implementation calls CollectVoiceRope for the voice rope referenced in the deleted interest entry. If the class is given as NIL, then all classes are garbage collected.
Doug Terry, June 13, 1986 11:03:54 am PDT
Added reporting and class registration.
changes to: DIRECTORY, VoiceCleanup