-- UZoneTrackerImpl.Mesa
-- last edited January 11, 1983 11:58 am by Paul Rovner

DIRECTORY
UZoneTracker USING[];

UZoneTrackerImpl: MONITOR -- protects uzl
EXPORTS UZoneTracker

= BEGIN

uzl: LIST OF UNCOUNTED ZONENIL;

Register: PUBLIC ENTRY PROC[uz: UNCOUNTED ZONE] =
{ENABLE UNWIND => NULL; uzl ← CONS[uz, uzl]};

UnRegister: PUBLIC ENTRY PROC[uz: UNCOUNTED ZONE] =
{ENABLE UNWIND => NULL;
last: LIST OF UNCOUNTED ZONENIL;
FOR l: LIST OF UNCOUNTED ZONE ← uzl, l.rest UNTIL l = NIL
DO IF l.first = uz
THEN {IF last = NIL THEN uzl ← l.rest ELSE last.rest ← l.rest;
RETURN}
ELSE last ← l
ENDLOOP;
ERROR;
};

Enumerate: PUBLIC ENTRY PROC[proc: PROC[UNCOUNTED ZONE] RETURNS[stop: BOOL]]
RETURNS[uz: UNCOUNTED ZONENIL] =
{ENABLE UNWIND => NULL;
FOR l: LIST OF UNCOUNTED ZONE ← uzl, l.rest UNTIL l = NIL
DO IF proc[l.first] THEN RETURN[l.first] ENDLOOP;
};

END.