-- PipeImpl.mesa
-- Last changed by Doug Wyatt, September 22, 1980 5:32 PM

DIRECTORY
Pipe,
Area USING [Handle, Free],
Memory USING [NewZone];

PipeImpl: PROGRAM
IMPORTS Memory,Area,Pipe
EXPORTS Pipe SHARES Pipe = {
OPEN Pipe;

PipeError: PUBLIC SIGNAL = CODE;

zone: UNCOUNTED ZONE = Memory.NewZone["PipeImpl"];

procs: LONG POINTER TO READONLY Pipe.Procs = zone.NEW[Pipe.Procs = [
Put: SinkPut,
Free: SinkFree
]];

sink: Handle = zone.NEW[Pipe.Object ← [procs: procs, data: NIL]];

Sink: PUBLIC PROC RETURNS[Handle] = {
RETURN[Pipe.Ref[sink]];
};

SinkPut: PROCEDURE[self: Pipe.Handle, area: Area.Handle] = {
Area.Free[@area]
};

SinkFree: PROCEDURE[self: Pipe.Handle] = {
SIGNAL PipeError;
};

}.