-- DummyFileMapObjectImpl.mesa         Last edit: KK     October 26, 1982 12:34 pm

DIRECTORY

      AlpineEnvironment
	    USING[FileID, VolumeID],
      AlpineInternal
         USING[FPMFileHandle, LogMapHandle],
      DummyFileMapPrivate
         USING[FileObject, HorribleError],
      FileMap;


DummyFileMapObjectImpl: MONITOR LOCKS handle USING handle: Handle
  IMPORTS AE: AlpineEnvironment, AI: AlpineInternal, FMP: DummyFileMapPrivate
  EXPORTS AlpineInternal, FileMap, DummyFileMapPrivate =


BEGIN

Handle: TYPE = REF FileObject;
FileObject: PUBLIC TYPE = FMP.FileObject;

 
-- Increments use count on the supplied handle.

RegisterHandle: PUBLIC PROCEDURE[handle: Handle] =
   BEGIN
   IF handle.useCount < 1
      THEN ERROR FMP.HorribleError; -- bug catcher.
   MonitoredRegisterHandle[handle];
   IF handle.useCount <= 1
      THEN ERROR FMP.HorribleError; -- bug catcher.
   END;


-- called from RegisterHandle and Register.

MonitoredRegisterHandle: PUBLIC ENTRY PROCEDURE[handle: Handle] =
   BEGIN
   ENABLE UNWIND => NULL;
   handle.useCount ← handle.useCount + 1;
   END;


-- called from Unregister.

MonitoredUnregisterHandle: PUBLIC ENTRY PROCEDURE[handle: Handle,
 ReleaseProc: PROCEDURE[handle: Handle]] =
   BEGIN
   ENABLE UNWIND => NULL;
   IF handle.useCount = 0 THEN ERROR FMP.HorribleError;
   IF (handle.useCount ← handle.useCount - 1) = 0
      THEN ReleaseProc[handle];
   END;


-- asserts useCount is up, so we can read.

GetVolumeID: PUBLIC PROCEDURE[handle: Handle] RETURNS [volume:
 AE.VolumeID] =
   BEGIN
   RETURN[handle.volID];
   END;
   
   
-- asserts useCount is up, so we can read.

GetFileID: PUBLIC PROCEDURE[handle: Handle] RETURNS [file: AE.FileID] =
   BEGIN
   RETURN[handle.fileID];
   END;


GetVolumeIDAndFileID: PUBLIC PROCEDURE [handle: Handle] RETURNS [volume:
 AE.VolumeID, file: AE.FileID] =
   BEGIN
   RETURN[handle.volID, handle.fileID];
   END;
 
 
 VerifyLogMapHandle: PUBLIC PROCEDURE [handle: Handle, proc: PROCEDURE RETURNS
   [AI.LogMapHandle]] RETURNS [logMapHandle: AI.LogMapHandle] =
    BEGIN
    ENABLE UNWIND => NULL;
    IF handle.logMapHandle = NIL THEN handle.logMapHandle ← proc[];
    RETURN[handle.logMapHandle];
    END;
    
    
 VerifyFilePageMgrHandle: PUBLIC PROCEDURE [handle: Handle, proc: PROCEDURE RETURNS
   [AI.FPMFileHandle]] RETURNS [filePageMgrHandle: AI.FPMFileHandle] =
    BEGIN
    ENABLE UNWIND => NULL;
    IF handle.fPMFileHandle = NIL THEN handle.fPMFileHandle ← proc[];
    RETURN[handle.fPMFileHandle];
    END;
    
    
      

-- Procedure to enter the FileObject's monitor.

Enter: PUBLIC ENTRY PROCEDURE[handle: Handle, proc: PROCEDURE] =
   BEGIN
   ENABLE UNWIND => NULL;
   proc[];
   END;
   




END.

					Edit Log

Initial: Kolling: 13-Apr-82 13:53:34: an impl module for FileMap.