from AR 294 and 1049 --
XMesaCmplr19: MONITOR LOCKS manager.lock.l USING manager: Manager =
BEGIN
From HandleManager.mesa:
HandleProc: TYPE = PROCEDURE [handle: Handle, context: POINTER]
RETURNS [stop: BOOLEANFALSE];
Cache: TYPE = POINTER;
ErrorType: TYPE = {
handlesExist, -- can't Clear unless all handles are gone, if mustBeEmpty
invalidHandle}; -- the handle is not a valid one
Manager: TYPE = POINTER TO Object;
Object: 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: TYPE = PACKED RECORD [
stamp: CARD16, -- timestamp
index: CARD16]; -- index into vector
currentStamp: CARD16 ← 0;
Error: ERROR [type: ErrorType] = CODE;
DestroyHandle: ENTRY PROCEDURE [handle: Handle, manager: Manager] =
BEGIN
ENABLE UNWIND => NULL;
[] ← ValidateHandle[handle, manager ! Error => GOTO invalid];
manager.vector.z.FREE[@manager.vector[handle.index]]; -- also clears HandleReference
EXITS invalid => RETURN WITH ERROR Error[invalidHandle];
END; -- of DestroyHandle
GetCache: ENTRY PROCEDURE [handle: Handle, manager: Manager]
RETURNS [cache: Cache] = {
ENABLE UNWIND => NULL;
RETURN[@ValidateHandle[handle, manager ! Error => GOTO invalid].cache]
EXITS invalid => RETURN WITH ERROR Error[invalidHandle]};
SetDebugData: ENTRY PROCEDURE [
handle: Handle, program, key: UNSPEC16, manager: Manager] =
BEGIN
ENABLE UNWIND => NULL;
reference: HandleReference ← ValidateHandle[
handle, manager ! Error => GOTO invalid];
reference.program ← program;
reference.key ← key;
EXITS invalid => RETURN WITH ERROR Error[invalidHandle];
END; -- of SetDebugData
GetDebugData: ENTRY PROCEDURE [handle: Handle, manager: Manager]
RETURNS [program, key: UNSPEC16] =
BEGIN
ENABLE UNWIND => NULL;
reference: HandleReference ← ValidateHandle[
handle, manager ! Error => GOTO invalid];
RETURN[reference.program, reference.key];
EXITS invalid => RETURN WITH ERROR Error[invalidHandle];
END;
ValidateHandle: PROCEDURE [handle: Handle, manager: Manager]
RETURNS [reference: HandleReference ← NIL] =
BEGIN
END;
END.