File Queue.mesa
Copyright (C) Xerox Corporation 1981, 1982, 1983, 1984, 1985, 1986. All rights reserved.
last edited by Strickberger 19-Jul-85 1:28:55
Tim Diebert: October 2, 1986 1:51:30 pm PDT
DIRECTORY
Process USING [DisableTimeout, EnableAborts];
Queue: DEFINITIONS LOCKS queue USING queue: Handle IMPORTS Process = BEGIN
Constants:
length: CARDINAL = 12;
TYPEs:
Handle: TYPE = LONG POINTER TO Object;
Item: TYPE = UNSPECIFIED;
Object: TYPE = MONITORED RECORD [
body: ARRAY [FIRST[CARDINAL]..length) OF Item,
head, tail: CARDINALFIRST[CARDINAL],
nonEmpty: CONDITION];
INLINE ENTRY PROCEDUREs:
Empty: ENTRY PROCEDURE [queue: Handle] RETURNS [empty: BOOLEAN] = INLINE
BEGIN ENABLE UNWIND => NULL; RETURN[empty: queue.tail = queue.head]; END;
Full: ENTRY PROCEDURE [queue: Handle] RETURNS [full: BOOLEAN] = INLINE BEGIN
ENABLE UNWIND => NULL;
RETURN[full: (queue.tail + 1) MOD length = queue.head];
END;
Initialize: ENTRY PROCEDURE [queue: Handle] = TRUSTED INLINE BEGIN
ENABLE UNWIND => NULL;
local: Object ← queue^;
Process.DisableTimeout[condition: @local.nonEmpty];
Process.EnableAborts[pCondition: @local.nonEmpty];
RETURN;
END;
Pop: ENTRY PROCEDURE [queue: Handle] RETURNS [item: Item] = INLINE BEGIN
ENABLE UNWIND => NULL;
IF queue.tail = queue.head THEN WAIT queue.nonEmpty;
item ← queue.body[queue.head];
queue.head ← SUCC[queue.head] MOD length;
RETURN;
END;
Push: ENTRY PROCEDURE [queue: Handle, item: Item] = INLINE BEGIN
ENABLE UNWIND => NULL;
queue.body[queue.tail] ← item;
queue.tail ← SUCC[queue.tail] MOD length;
NOTIFY queue.nonEmpty;
RETURN;
END;
END.
LOG
When / Who / What.
81/Claude Pany/Created.
11-Apr-83 14:39:32 - Trowell - created QueueImpl and removed INLINEs here for Sierra compiler bug workaround
10-Oct-83 3:34:28 - Strickberger - Restored INLINEs and deleted Impl. POINTERLONG POINTER for Klamth
19-Jul-85 1:28:55 - Strickberger - Add copyright. FixArrows.