VoiceCleanup.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Doug Terry, June 26, 1986 2:19:03 pm PDT
Routines for collecting voice ropes that have no external references to them, i.e. are "garbage".
DIRECTORY
IO USING [STREAM],
Rope USING [ROPE],
VoiceRopeDB USING [InterestInfo];
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 [reports: STREAMNIL] 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 [reports: STREAMNIL] 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 [BOOLEANFALSE];
RegisterClass: PROC [class: ROPE, proc: IsGarbageProc] RETURNS [];
Registers an IsGarbageProc to be used when garbage collecting interests of the given class.
CollectInterests: PROC [class: ROPENIL, reports: STREAMNIL] 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.
END.
Doug Terry, June 6, 1986 4:14:05 pm PDT
Created. 
changes to: DIRECTORY, VoiceCleanup, END
Doug Terry, June 10, 1986 6:07:52 pm PDT
changes to: DIRECTORY, VoiceCleanup
Doug Terry, June 13, 1986 11:03:54 am PDT
Added reporting and class registration.
changes to: DIRECTORY, VoiceCleanup
Doug Terry, June 26, 1986 2:19:03 pm PDT
changes to: VoiceCleanup
Doug Terry, November 18, 1986 5:00:50 pm PST
Removed database name as an argument to collection routines; there can be at most one VoiceRope database at a given time.
changes to: VoiceCleanup