Queue.mesa
This queue cluster was written specifically for the SMTPQueue module. It is not intended to be general purpose. Elements of the queue are inhibitable REF ANYs. Elements may be added to the end of a queue, may be deleted from the front of or within the queue, and the queue may be checked for empty and enumerated. Elements may be inhibited for a specified amount of time and specified reason, and this inhibition may be checked or cancelled.
Last Edited by: HGM, April 11, 1984 11:52:31 pm PST
Last Edited by: DCraft, December 21, 1983 2:27 pm
Last Edited by: Taft, January 22, 1984 12:39:19 pm PST
DIRECTORY
BasicTime USING [GMT],
Rope USING [ROPE];
Queue: CEDAR DEFINITIONS =
BEGIN
MQ: TYPE = REF MQRep;
MQRep: TYPE;
QElem: TYPE = REF QElemRep;
QElemRep: TYPE;
ROPE: TYPE = Rope.ROPE;
GMT: TYPE = BasicTime.GMT;
Queue and Element Creation, Enqueueing, Dequeueing, and Enumeration
NewElem: PROC [value: REF ANY] RETURNS [newElem: QElem];
Create a new queue element from the given value.
Value: PROC [qElem: QElem] RETURNS [value: REF ANY];
Retrieve the element value.
Create: PROC [name: ROPE] RETURNS [newQueue: MQ];
Create a new queue.
Name: PROC [queue: MQ] RETURNS [ROPE];
Retrieve the queue name.
IsEmpty: PROC [queue: MQ] RETURNS [BOOL];
Is the queue empty?
Enqueue: PROC [queue: MQ, qElem: QElem];
Place element at end of queue, waiting no later than expiryTime for the lock. Raise LockNotObtained if wait time exceeded.
Dequeue: PROC [queue: MQ, value: REF ANY];
Remove the first occurrence of value from the queue. Raise NotOnQueue if no occurrence found.
NotOnQueue: ERROR;
GetHead: PROC [queue: MQ] RETURNS [qElem: QElem];
Returns the first element on the queue, without Dequeueing it. NIL if empty.
GetProcessableElement: PROC [queue: MQ] RETURNS [qElem: QElem];
Returns the first uninhibited element on the queue, without Dequeueing it. NIL if empty.
QueueEmpty: ERROR;
Enumerate: PROC [queue: MQ, proc: ElemProc, procData: REF ANYNIL];
Call the given proc for each element in the queue.
ElemProc: TYPE = PROC[qElem: QElem, procData: REF ANYNIL] RETURNS [continue: BOOLTRUE];
Inhibition
Inhibit: PROC [qElem: QElem, for --seconds--: INT, why: ROPE];
Inhibit the element for the given time and reason.
Uninhibit: PROC [qElem: QElem, queue: MQ];
Cancel inhibition of the given element.
Inhibition: PROC [qElem: QElem] RETURNS [for: INT, why: ROPE];
Return inhibtion status of element.
END.