FIFOQueue.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, September 16, 1986 10:44:49 am PDT
Last edited by: Christian Jacobi, September 16, 1986 2:12:18 pm PDT
FIFOQueue: CEDAR DEFINITIONS =
BEGIN
Abstraction for simple first in first out queues of arbitrary length.
Queue: TYPE = REF QueueRec;
QueueRec: TYPE = PRIVATE MONITORED RECORD [front, tail: LIST OF REF ANYNIL, cond: CONDITION];
Create: PROC [] RETURNS [queue: Queue];
Creates a new, empty queue.
Include: PROC [queue: Queue, value: REF];
Includes value at tail of queue
Remove: PROC [queue: Queue] RETURNS [value: REF];
Removes value from front of queue
Raises Empty if queue was empty [without damage to queue]
Empty: ERROR; --Logically a SIGNAL which can't be resumed
RemoveNWait: PROC [queue: Queue] RETURNS [value: REF];
Removes value from front of queue
If queue is empty, waits until value can be returned
IsEmpty: PROC [queue: Queue] RETURNS [BOOL];
Checks whether queue is empty
Call is trustworthy only if its process is the only one handling the queue
Flush: PROC [queue: Queue];
Discards all entries in queue
END.