FanoutStream.mesa
Copyright Ó 1991, by Xerox Corporation. All rights reserved.
Christian Jacobi, July 8, 1991 11:33 am PDT
Last tweaked by Mike Spreitzer March 20, 1992 2:13 pm PST
Another stream class.
DIRECTORY IO USING [STREAM];
FanoutStream: CEDAR DEFINITIONS
~ BEGIN
Fanout Stream
Create: PROC [reportErrors: BOOL ¬ FALSE, forwardClose: BOOL ¬ FALSE] RETURNS [master: IO.STREAM];
Creates an output stream master such that each operation performed on master will be performed on all registered slaves (in undefined order).
If reportErrors and a slave stream raises an error this error is propagated to caller, otherwise slave errors are ignored.
If forwardClose and the master stream is closed, all slave streams will be closed, otherwise close is not forwarded.
AddSlave: PROC [master: IO.STREAM, slave: IO.STREAM];
Registers slave to receive any operations on master. Errors or close operation on slave may remove it from the list of registered slaves.
Beware of cycles or duplicates.
RemoveSlave: PROC [master: IO.STREAM, slave: IO.STREAM];
Unregisters slave from master. NoOp if slave not registered with master.
END.