from AR 294 --
XMesaCmplr18: MONITOR LOCKS manager.lock.l USING manager: Manager = BEGIN
Manager: TYPE = POINTER TO Object;
Object: PUBLIC TYPE = PACKED RECORD [
lock: POINTER TO Lock,
vector: POINTER TO Vector,
initialSize, growBy: [0..256)];
Vector: TYPE = RECORD [
z: UNCOUNTED ZONE, handles: SEQUENCE count: CARD16 OF HandleReference];
HandleReference: TYPE = POINTER TO HandleRecord;
HandleRecord: TYPE = RECORD [
stamp: CARD16, -- timestamp
program, key: UNSPEC16, -- debug data
cache: SEQUENCE COMPUTED CARD16 OF UNIT]; -- client's cache
Lock: TYPE = RECORD [l: MONITORLOCK];
Handle: PUBLIC TYPE = PACKED RECORD [
stamp: CARD16,
index: CARD16];
Cache: TYPE = POINTER;
CreateHandle: PUBLIC ENTRY PROCEDURE [cacheSize: CARD16, manager: Manager]
RETURNS [handle: Handle, cache: --HandleManager.--Cache] =
BEGIN
handle ← [1, 2];
manager.vector[handle.index] ← manager.vector.z.NEW[
HandleRecord [cacheSize] ← [
stamp: handle.stamp, program: 0, key: 0, cache:]];
cache ← @manager.vector[1].cache;
END;
END.