mentor/derived/PQueueIE.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file PQueue.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE PQueueIE;

<*NOWARN*> IMPORT PQueue, ZeusClass, Zeus, Algorithm;
<*NOWARN*> IMPORT PQueueAlgClass, View, Thread, PQueueViewClass;
<*NOWARN*> IMPORT AlgorithmClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  SetupArgs = BRANDED REF RECORD
    size: INTEGER;
    doSort: BOOLEAN;
  END;

  InitSortArgs = BRANDED REF RECORD
    vals: PQueue.Array;
  END;

  InsertArgs = BRANDED REF RECORD
    el: INTEGER;
  END;

  HeapOpInitArgs = BRANDED REF RECORD
    k: INTEGER;
  END;

  UpHeapStepArgs = BRANDED REF RECORD
    k: INTEGER;
  END;

  HeapStepArgs = BRANDED REF RECORD
    k: INTEGER;
    n: INTEGER;
    down: BOOLEAN;
  END;

  PlaceElementArgs = BRANDED REF RECORD
    k: INTEGER;
  END;

  RemoveArgs = BRANDED REF RECORD
  END;

  CompareArgs = BRANDED REF RECORD
    k: INTEGER;
    n: INTEGER;
  END;

  PauseArgs = BRANDED REF RECORD
  END;

  SortStepArgs = BRANDED REF RECORD
    k: INTEGER;
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | PQueueViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              varSetupArgs.size
                ,
              varSetupArgs.doSort
              )
      | InitSortArgs(varInitSortArgs) => <*NOWARN*>
          view.oeInitSort (
              varInitSortArgs.vals
              )
      | InsertArgs(varInsertArgs) => <*NOWARN*>
          view.oeInsert (
              varInsertArgs.el
              )
      | HeapOpInitArgs(varHeapOpInitArgs) => <*NOWARN*>
          view.oeHeapOpInit (
              varHeapOpInitArgs.k
              )
      | UpHeapStepArgs(varUpHeapStepArgs) => <*NOWARN*>
          view.oeUpHeapStep (
              varUpHeapStepArgs.k
              )
      | HeapStepArgs(varHeapStepArgs) => <*NOWARN*>
          view.oeHeapStep (
              varHeapStepArgs.k
                ,
              varHeapStepArgs.n
                ,
              varHeapStepArgs.down
              )
      | PlaceElementArgs(varPlaceElementArgs) => <*NOWARN*>
          view.oePlaceElement (
              varPlaceElementArgs.k
              )
      | RemoveArgs(varRemoveArgs) => <*NOWARN*>
          view.oeRemove (
              )
      | CompareArgs(varCompareArgs) => <*NOWARN*>
          view.oeCompare (
              varCompareArgs.k
                ,
              varCompareArgs.n
              )
      | PauseArgs(varPauseArgs) => <*NOWARN*>
          view.oePause (
              )
      | SortStepArgs(varSortStepArgs) => <*NOWARN*>
          view.oeSortStep (
              varSortStepArgs.k
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a PQueueViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | PQueueAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a PQueueAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE Setup (
      initiator: Algorithm.T;
       size: INTEGER; doSort: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
               , size := size
               , doSort := doSort
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Setup", OEDispatcher, zumeArgRec);
    END;
  END Setup;

PROCEDURE InitSort (
      initiator: Algorithm.T;
       vals: PQueue.Array
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(InitSortArgs
               , vals := vals
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfInitSort);
      alg.stopAtEvent := alg.eventDataRec.stopAtInitSort;
      alg.waitAtEvent := alg.eventDataRec.waitAtInitSort;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "InitSort", OEDispatcher, zumeArgRec);
    END;
  END InitSort;

PROCEDURE Insert (
      initiator: Algorithm.T;
       el: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(InsertArgs
               , el := el
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfInsert);
      alg.stopAtEvent := alg.eventDataRec.stopAtInsert;
      alg.waitAtEvent := alg.eventDataRec.waitAtInsert;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Insert", OEDispatcher, zumeArgRec);
    END;
  END Insert;

PROCEDURE HeapOpInit (
      initiator: Algorithm.T;
       k: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HeapOpInitArgs
               , k := k
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHeapOpInit);
      alg.stopAtEvent := alg.eventDataRec.stopAtHeapOpInit;
      alg.waitAtEvent := alg.eventDataRec.waitAtHeapOpInit;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HeapOpInit", OEDispatcher, zumeArgRec);
    END;
  END HeapOpInit;

PROCEDURE UpHeapStep (
      initiator: Algorithm.T;
       k: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(UpHeapStepArgs
               , k := k
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfUpHeapStep);
      alg.stopAtEvent := alg.eventDataRec.stopAtUpHeapStep;
      alg.waitAtEvent := alg.eventDataRec.waitAtUpHeapStep;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "UpHeapStep", OEDispatcher, zumeArgRec);
    END;
  END UpHeapStep;

PROCEDURE HeapStep (
      initiator: Algorithm.T;
       k, n: INTEGER; down: BOOLEAN
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HeapStepArgs
               , k := k
               , n := n
               , down := down
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHeapStep);
      alg.stopAtEvent := alg.eventDataRec.stopAtHeapStep;
      alg.waitAtEvent := alg.eventDataRec.waitAtHeapStep;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HeapStep", OEDispatcher, zumeArgRec);
    END;
  END HeapStep;

PROCEDURE PlaceElement (
      initiator: Algorithm.T;
       k: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PlaceElementArgs
               , k := k
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPlaceElement);
      alg.stopAtEvent := alg.eventDataRec.stopAtPlaceElement;
      alg.waitAtEvent := alg.eventDataRec.waitAtPlaceElement;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "PlaceElement", OEDispatcher, zumeArgRec);
    END;
  END PlaceElement;

PROCEDURE Remove (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(RemoveArgs
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfRemove);
      alg.stopAtEvent := alg.eventDataRec.stopAtRemove;
      alg.waitAtEvent := alg.eventDataRec.waitAtRemove;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Remove", OEDispatcher, zumeArgRec);
    END;
  END Remove;

PROCEDURE Compare (
      initiator: Algorithm.T;
       k: INTEGER; n: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(CompareArgs
               , k := k
               , n := n
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfCompare);
      alg.stopAtEvent := alg.eventDataRec.stopAtCompare;
      alg.waitAtEvent := alg.eventDataRec.waitAtCompare;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Compare", OEDispatcher, zumeArgRec);
    END;
  END Compare;

PROCEDURE Pause (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PauseArgs
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPause);
      alg.stopAtEvent := alg.eventDataRec.stopAtPause;
      alg.waitAtEvent := alg.eventDataRec.waitAtPause;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Pause", OEDispatcher, zumeArgRec);
    END;
  END Pause;

PROCEDURE SortStep (
      initiator: Algorithm.T;
       k: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SortStepArgs
               , k := k
      );
      alg := NARROW(initiator, PQueueAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSortStep);
      alg.stopAtEvent := alg.eventDataRec.stopAtSortStep;
      alg.waitAtEvent := alg.eventDataRec.waitAtSortStep;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "SortStep", OEDispatcher, zumeArgRec);
    END;
  END SortStep;

BEGIN
END PQueueIE.

interface View is in: