-- Pipe.mesa
-- Last changed by Doug Wyatt, September 19, 1980 11:44 AM
DIRECTORY
Area USING [Handle];
Pipe: DEFINITIONS = {
Handle: TYPE = LONG POINTER TO Object;
Sink: PROC RETURNS[Handle];
Put: PROC[self: Handle, area: Area.Handle] = INLINE {
IF area#NIL THEN self.procs.Put[self,area]
};
Ref: PROC[self: Handle] RETURNS[Handle] = INLINE {
self.refs←self.refs+1; RETURN[self]
};
Free: PROC[selfPtr: LONG POINTER TO Handle] = INLINE {
self: Handle=selfPtr↑; selfPtr↑←NIL;
IF (self.refs←self.refs-1)=0 THEN self.procs.Free[self]
};
Object: PRIVATE TYPE = RECORD [
procs: LONG POINTER TO READONLY Procs,
data: LONG POINTER TO Data,
refs: CARDINAL←1
];
Procs: PRIVATE TYPE = RECORD [
Put: PROC[self: Handle, area: Area.Handle],
Free: PROC[self: Handle]
];
Data: PRIVATE TYPE;
PipeImpl: PROGRAM;
}.