-- File: IFSFileOpsC.mesa
-- Last edited by Levin:  28-Jan-81 17:42:06

DIRECTORY
  IFSFilePrivate USING [IORequest, IORequestBlock],
  VMStorage USING [longTerm];

IFSFileOpsC: MONITOR IMPORTS VMStorage 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;
      VMStorage.longTerm.FREE[@request];
      ENDLOOP;
    END;

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

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

  END.