-- File: QueueCool.mesa, Last Edit: JGS February 7, 1980 9:11 AM
-- Copyright Xerox Corporation 1979, 1980
DIRECTORY
DriverDefs: FROM "DriverDefs" USING [dataWordsPerBuffer],
PupDefs: FROM "PupDefs", -- EXPORTs
BufferDefs: FROM "BufferDefs" USING [
Buffer, BufferObject, Queue, Dequeue, ReturnFreeBuffer],
DriverTypes: FROM "DriverTypes" USING [queueSeal];
QueueCool: PROGRAM
IMPORTS DriverDefs, BufferDefs
EXPORTS PupDefs, BufferDefs, DriverDefs
SHARES BufferDefs =
BEGIN OPEN DriverDefs, BufferDefs;
rawOverhead: CARDINAL = SIZE[raw BufferDefs.BufferObject];
pupOverhead: CARDINAL = SIZE[pupWords pup BufferDefs.BufferObject]+1;
overhead: CARDINAL = MAX[
pupOverhead,
SIZE[rppWords rpp BufferDefs.BufferObject]+1];
DataWordsPerPupBuffer: PUBLIC PROCEDURE RETURNS [CARDINAL] =
BEGIN
RETURN[DriverDefs.dataWordsPerBuffer+(overhead-pupOverhead)];
END;
DataWordsPerRawBuffer: PUBLIC PROCEDURE RETURNS [CARDINAL] =
BEGIN
RETURN[DriverDefs.dataWordsPerBuffer+(overhead-rawOverhead)];
END;
QueueInitialize: PUBLIC PROCEDURE [q: Queue] =
BEGIN
q↑ ← [ length: 0, first: NIL, last: NIL, seal: DriverTypes.queueSeal ];
END;
-- put all buffers back onto freeQueue
QueueCleanup: PUBLIC PROCEDURE [q: Queue] =
BEGIN
b: Buffer;
UNTIL (b←Dequeue[q])=NIL DO ReturnFreeBuffer[b]; ENDLOOP;
END;
-- initialization
END. -- QueueCool