PDQueue.mesa
Copyright (C) 1984, 1985, Xerox Corporation. All rights reserved.
Michael Plass, October 31, 1984 10:19:10 am PST
Tim Diebert: September 19, 1985 2:46:42 pm PDT
PDQueue:
DEFINITIONS =
BEGIN
This module manages the queue for the peach printer. If a disk is available, a simple mechanism is provided here for periodically saving the state of the queue on the disk, so booting the server will not lose it all. In any case, the queue lives in main memory, and consists mostly of full path names of the files, together with a little bit of information about who requested the print, etc. There is also some stuff here for logging what has been going on, and for accessing the log.
ROPE: TYPE ~ Rope.ROPE;
Request:
TYPE =
RECORD [
fileName: ROPE, -- i.e., "[Indigo]<platemaker>foo.pd!33".
requestTime: ROPE,
requestor: ROPE,
requestorPassword: ROPE,
separator: ROPE, -- To be printed between jobs, if possible.
copies: CARDINAL
];
Reset:
PROC;
Resets the queue.
QueueRequest:
PROC [request: Request]
RETURNS [requestNumber:
INT];
Returns -1 if the queue is full.
Reprint:
PROC [copies:
CARDINAL];
ReprintCancelled:
PROC
RETURNS [
BOOLEAN];
DoRequest:
PROC [action:
PROC [request: Request, requestNumber:
CARDINAL,
abort:
REF
BOOLEAN]];
Waits if queue is empty; action should return or raise ABORTED if abort^ becomes true.
If the strings in the Request are NIL, the request is to reprint as much as the previous request as is possible without a lot of recomputation.
CheckRequest:
PROC [requestNumber:
CARDINAL, action:
PROC [request: Request, status: RequestStatus]];
RequestStatus: TYPE = {notFound, canceled, waiting, printing};
CancelRequest:
PROC [requestNumber:
CARDINAL]
RETURNS [ok:
BOOLEAN];
Looks for a matching request (fileName and requestor), and removes it from the queue.
CountRequests:
PROC
RETURNS [requestCount:
NAT];
Number of outstanding requests.
EnumerateRequests:
PROC [action:
PROC [requestNumber:
CARDINAL, request: Request, status: RequestStatus]
RETURNS [continue:
BOOLEAN]];
RegisterDisk:
PROC [file:
ROPE ←
NIL];
Determins the disk file name of the queue. If NIL, no queue is kept on disk.
RegisterTTY:
PROC [stream:
IO.
STREAM];
Registers a proc for displaying messages.
GetSuspended: PROC RETURNS [BOOLEAN];
SetSuspended:
PROC [suspended:
BOOLEAN]
RETURNS [old:
BOOLEAN];
Setting suspended to TRUE will stop printing after the current job finishes.
LogMessage:
PROC [message:
ROPE, requestNumber:
INT ← -1, userName:
ROPE ←
NIL, printCR:
BOOL ←
TRUE];
Adds time stamp. Message is also output to the printer's TTY, if present and enabled.
SetLogState:
PROC [logging:
BOOLEAN]
RETURNS [old:
BOOLEAN];
Setting logging to FALSE prevents messages from being logged on the TTY, to prevent interference with typein. Unprinted messages will be printed when logging is re-enabled.
EnumerateMessages:
PROC [
PROC[message:
ROPE]
RETURNS [continue:
BOOLEAN]];
Replays history for as far back as we can remember.
DeferSaving:
PROC;
Prevents operations that normally checkpoint the queue on disk from doing so,
for example to prevent contention for the disk while actually printing.
DoDeferredSave:
PROC;
Does any deferred checkpoints;
END.