-- Transport Mechanism Registration Server - Access to the B-Tree --

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

-- Andrew Birrell  27-Oct-82 15:56:08 --

DIRECTORY
  BodyDefs: FROM "BodyDefs" USING [RName, Timestamp],
  HeapDefs: FROM "HeapDefs" USING [ObjectNumber, ReaderHandle, WriterHandle],
  ProtocolDefs: FROM "ProtocolDefs" USING [RNameType];

RegBTreeDefs: DEFINITIONS =
  BEGIN

  RegBTree: PROGRAM;

  RegistryObject: TYPE = RECORD [
    type: ProtocolDefs.RNameType,
    stamp: BodyDefs.Timestamp,
    reader: HeapDefs.ReaderHandle];

  LookupReason: TYPE = {readNone, readGroup, readIndividual, readEither, readAny};

  Lookup: PROCEDURE [name: BodyDefs.RName, reason: LookupReason]
    RETURNS [info: RegistryObject];


  Insert: PROCEDURE [
    name: BodyDefs.RName, type: ProtocolDefs.RNameType,
    stamp: POINTER TO BodyDefs.Timestamp, writer: HeapDefs.WriterHandle,
    info: POINTER TO RegistryObject];


  KnownRegistry: PROC [name: BodyDefs.RName, yes: BOOLEAN];

  -- Record that the entry (which is a group in the GV registry) is/isnt
  -- a registry known locally.


  RegState: TYPE = {
    yes --local registry-- , no --non-local registry-- , bad --not a registry-- };

  TestKnownReg: PROC [name: BodyDefs.RName] RETURNS [state: RegState];

  -- Tells whether the name is/isnt in a registry which is recorded as a
  -- registry known locally.


  UpdateFailed: ERROR [info: RegistryObject];

  -- this is raised by Insert if the relevant B-Tree entry differs from the
  -- entry that existed when the corresponding Lookup was performed. 
  -- The update should be re-calculated.  The parameter of this signal is
  -- the info produced now by a lookup of the B-Tree.  This is the primary
  -- means of synchronising on accesses to the registration server's
  -- B-Tree. --


  EnumerateTree: PROCEDURE [
    type: ProtocolDefs.RNameType, action: PROCEDURE [BodyDefs.RName]];

  -- calls "action" for each entry in the B-Tree of the given type --


  MarkKnown: SIGNAL;

  -- Ugh!  But it's upwards compatible.  Raised during EnumerateTree to
  -- request that entry be marked as a known registry.


  KeepObject: PROCEDURE [
    name: BodyDefs.RName, type: ProtocolDefs.RNameType,
    stamp: POINTER TO BodyDefs.Timestamp, number: HeapDefs.ObjectNumber];

  -- Called for object found during the restart sequence, only --


  RegPurger: PROC;
  -- forks the RS BTree purger process --


  END.