PDQueue.mesa
Copyright (C) 1984, Xerox Corporation. All rights reserved.
Michael Plass, October 31, 1984 10:19:10 am PST
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.
Request: TYPE = RECORD [
fileName: LONG STRING,
i.e., "[Indigo]<platemaker>foo.pd!33".
requestTime: LONG STRING,
requestor: LONG STRING,
requestorPassword: LONG STRING,
separator: LONG STRING,
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];
CancelReprint: PROC;
ReprintCancelled: PROC RETURNS [BOOLEAN];
DoRequest: PROC [action: PROC [request: Request, requestNumber: CARDINAL, abort: LONG POINTER TO 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 [read, write: PROC [address: LONG POINTER, nwords: CARDINAL], maxWords: CARDINAL];
Periodically calls the write proc; calls the read proc at startup time. If this is never called, the queue lives only in main memory and is lost at boot time.
RegisterTTY: PROC [writeLine: PROC [LONG STRING]];
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: LONG STRING, requestNumber: INT ← -1, userName: LONG STRINGNIL];
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: LONG STRING] 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.