-- File: IFSFileImplD.mesa
-- Last edited by:
-- Levin - 30-Jun-81 17:29:53

DIRECTORY
  IFSFilePrivate USING [IORequest, IORequestBlock, zone];

IFSFileImplD: MONITOR
  IMPORTS IFSFilePrivate
  EXPORTS IFSFilePrivate =

  BEGIN OPEN IFSFilePrivate;


  -- Global Variables --

  freeList: IORequest;


  -- Procedures exported to IFSFilePrivate --

  InitializeFreeList: PUBLIC PROCEDURE =
    {freeList ← NIL};

  FinalizeFreeList: PUBLIC PROCEDURE =
    BEGIN
    UNTIL freeList = NIL DO
      request: IORequest ← freeList;
      freeList ← freeList.link;
      zone.FREE[@request];
      ENDLOOP;
    END;

  GetIORequestBlock: PUBLIC ENTRY PROCEDURE RETURNS [request: IORequest] =
    BEGIN
    IF freeList ~= NIL THEN {request ← freeList; freeList ← request.link}
    ELSE request ← zone.NEW[IORequestBlock];
    END;

  FreeIORequestBlock: PUBLIC ENTRY PROCEDURE [request: IORequest] =
    BEGIN
    request.link ← freeList; freeList ← request;
    END;

  END.