-- RealEvent.mesa, an interface for time-stamped streams of REAL values
-- Last Modified On 21-Jan-82 10:44:38 By Paul Rovner

DIRECTORY
      RefAnyStream USING[Handle];
      
RealEvent: DEFINITIONS =
 { 

--TYPEs
   Handle: TYPE = REF Object;
   Object: TYPE = RECORD[sampleValue: REAL, time: Seconds];
   StreamHandle: TYPE = RefAnyStream.Handle;

   Seconds: TYPE = REAL;

   
-- PROCEDUREs

   CreateTimerDrivenStream: PROC[interval: Seconds,
                                 sampler: PROC[REF ANY] RETURNS[REAL],
				 stateInfo: REF ANY ← NIL]
         RETURNS[StreamHandle];
	 -- This creates a new REF ANY stream for RealEvent.Handle's
	 -- and returns it. The "put" operation raises an error. "endOf"
	 -- and "empty" are not implemented yet. Subsequent to the return
	 -- of CreateTimerDrivenStream, sampler will be invoked every 
	 -- specified interval to provide a new data value. "stateInfo" 
	 -- is passed back to sampler when it is called. The value 
	 -- returned by sampler is bundled in a new Object with the 
	 -- time at which sampler returned. The new Handle is "put" 
	 -- onto the REF ANY stream. Closing the REF ANY stream will 
	 -- stop associated calls on sampler. BEWARE: don't forget to 
	 -- Close the REF ANY stream. It would be unwise to specify
	 -- an interval smaller than a couple of seconds. 
   
   CreateEventDrivenStream: PROC[] RETURNS[StreamHandle];
         -- This creates a new REF ANY stream for RealEvent.Handle's and 
	 -- returns it. "endOf" and "empty" are not implemented yet.
   
 }.