CDLRUCache.mesa a Chipndale module
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi March 7, 1984 5:59:42 pm PST
last change Christian October 22, 1984 2:33:51 pm PDT
CDLRUCache: CEDAR DEFINITIONS =
BEGIN
LRUCache: TYPE = REF LRUCacheRep;
LRUCacheRep: TYPE;
AequivalenceProc: TYPE = PROC[mySpecific, other: REF ANY] RETURNS [BOOL];
NewProc: TYPE = PROC [] RETURNS [CD.ObPtr];
Create:
PROC [size:
CARDINAL ← 17, aequivalenceProc: AequivalenceProc←
NIL, newProc: NewProc←
NIL]
RETURNS [LRUCache];
--creates new LRU cache of suggested size
--aequivalenceProc: procedure to check specificRef's for aequivalence
-- NIL means: aeqivalence if same REF's
--newProc: Procedure to allocate new objects;
-- NIL means: UnusedOrNew will never be called on this LRUCache
UnusedOrNew:
PROC [lruCache: LRUCache]
RETURNS [
CD.ObPtr];
--this procedure is defined only if Create of lruCache had a NewProc
--before allocating a new object with the newProc, it tries if
ReplaceByAequivalent:
PROC [lruCache: LRUCache, ob:
CD.ObPtr]
RETURNS [
CD.ObPtr];
--returns either "ob" or an aequivalent object to "ob"
--side effect: introduces "ob" in aequivalence table to be accessed by others.
--consider "ob" immutable! respectively, on any further change, it may cause
--the same change made to all or some aequivalent objects in past and future
END.