-- MonitoredQueue.Mesa
-- written by Paxton. December 1981
-- last written by Paxton. August 9, 1982 1:19 pm
Last Edited by: Maxwell, January 5, 1983 12:34 pm
MonitoredQueue: CEDAR DEFINITIONS =
BEGIN
MQ: TYPE = REF QueueBody;
QueueBody: TYPE;
Create: PROC [z: ZONENIL] RETURNS [MQ];
-- uses zone to allocate QueueBody and LIST OF REF's for the queue
-- if zone is NIL, will do allocates from system zone
Add: PROC [item: REF ANY, queue: MQ];
-- adds item to queue
-- causes ERROR QueueClosed if queue is closed
AddToSet: PROC [item: REF ANY, queue: MQ];
-- adds item to queue unless it is already in it
-- causes ERROR QueueClosed if queue is closed
QueueClosed, EndOfQueue: ERROR;
Remove: PROC [queue: MQ] RETURNS [REF ANY];
-- returns next item
-- will wait for next item to be added if queue has not been closed
-- causes ERROR EndOfQueue if have called Close[queue] and no more items
Close: PROC [queue: MQ];
-- to indicate that will not be adding any more items to MQ
Reset: PROC [queue: MQ];
-- this waits until queue is closed and empty, then reopens it
END.