-- Transport Mechanism Filestore - public DEFS for heap object management. --

-- [Juniper]<Grapevine>MS>ObjectDirDefs.mesa

-- Andrew Birrell  24-Feb-81 15:55:22 --

DIRECTORY
VMDefs		USING[ PageIndex, PageNumber ];
 
ObjectDirDefs:	DEFINITIONS = BEGIN

ObjectNumber:	TYPE = MACHINE DEPENDENT RECORD[
			page:  PRIVATE VMDefs.PageNumber,
			fill:  PRIVATE [0..16),
			type:  PUBLIC ObjectType,
			index: PRIVATE VMDefs.PageIndex ];

noObject:	ObjectNumber = [page:0, fill:0, type:gap, index:0];
   -- A value of "ObjectNumber" which is never be that of a heap object --

ObjectType:	TYPE = MACHINE DEPENDENT{
			gap(0)--internal--, body(1), SLinput(2), SLpending(3),
			SLforward(4), RSobject(5), RSmail(6), temp(7),
			RSname(8), MSname(9), testMode(10), TOC(11),
			archived(12), delArch(13), spare16(14), spare17(15)
			};
   -- types of object recorded in heap; limited by field in ObjectNumber
   -- (recorded in ObjectHeader on disk) --

UseObject:	PROC[ ObjectNumber ];
   -- Checks that reference count exceeds zero, then increments reference
   -- count --

FreeObject:	PROC[ ObjectNumber ];
   -- Checks that reference count exceeds zero, then decrements reference
   -- count --



-- Procedures used by clients while restarting --

RestartObject:	PROC[ ObjectNumber ];
   -- Increments reference count.  Unlike 'UseObject', will not complain if
   -- reference count was zero --

Enumerate:	PROC[ type: ObjectType,
		      proc: PROCEDURE[ObjectNumber]RETURNS[BOOLEAN] ]
		RETURNS[ ObjectNumber ];
   -- Calls "proc" in turn with the ObjectNumber of each object of the
   -- given type currently existing in the heap storage (excluding those
   -- which are still being written), until "proc" returns TRUE.  This may
   -- include objects whose reference count is zero.  If "proc" ever
   -- returns TRUE, this procedure returns the last object number that was
   -- given to "proc", otherwise this procedure returns "noObject". --

END.