DFOperationsQueue.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
Levin on December 6, 1983 9:22 am
Russ Atkinson (RRA) February 13, 1985 11:32:12 am PST
JKF December 5, 1988 10:52:02 am PST
DIRECTORY
DFOperations USING [BringOverAction, BringOverFilter, InteractionProc, SModelAction],
IO USING [STREAM],
Process USING [Priority, priorityBackground],
Rope USING [ROPE];
DFOperationsQueue: CEDAR DEFINITIONS = BEGIN OPEN IO, Rope;
This interface implements an asynchronous interface to the facilities defined in DFOperations. The central idea is a Queue, which is simply an ordered list of calls to be made on procedures in DFOperations. The calls in a given queue are executed in the order that they were entered on the queue; multiple queues proceed independently.
Queue: TYPE = REF QueueObject;
QueueObject: TYPE;
RequestedOp: TYPE = {bringOver, sModel, verify};
Request: TYPE = REF RequestRecord;
RequestRecord: TYPE = RECORD [
dfFile: ROPE,
wDir: ROPE, -- established for the duration of the operation only
interact: DFOperations.InteractionProc,
log: STREAM,
clientData: REF ANY,
opSpecific: SELECT op: RequestedOp FROM
bringOver => [filter: DFOperations.BringOverFilter, action: DFOperations.BringOverAction],
sModel => [action: DFOperations.SModelAction],
verify => NULL,
ENDCASE
];
NotifierProc: TYPE = PROC [queue: Queue, pending: LIST OF Request, clientData: REF ANY];
Create: PROC [priority: Process.Priority ¬ Process.priorityBackground, idleNotifier: NotifierProc ¬ NIL, clientData: REF ANY ¬ NIL] RETURNS [Queue];
This procedure creates and returns a queue. Requests to the DFOperations interface may be placed on the queue by calling `Enqueue'. If a non-NIL 'idleNotifier' is provided, it will be invoked when the 'queue' is empty, which may occur because all requests have been completed or because 'Abort' has been invoked.
Empty: PROC [queue: Queue] RETURNS [BOOL];
This procedure returns TRUE iff 'queue' has no pending requests.
Abort: PROC [queue: Queue];
The queue is emptied without the requests being executed and the queue's idleNotifier, if any, is invoked with the list of unexecuted requests as a parameter. Note that the operation at the head of the list may have been partially executed.
Enqueue: PROC [queue: Queue, request: Request];
The specified request is appended to the queue.
The 'interact' DFOperations.InteractionProc passed in a Request should be prepared to handle the following interaction in addition to the ones defined in the DFOperations interface.
OpTerminationInteraction: TYPE = RECORD [
op: RequestedOp,
dfFile: ROPE,
filesActedUpon: INT,
errors: INT,
warnings: INT
];
This interaction occurs when a queued operation completes, either normally or abnormally. 'op' and 'dfFile' define the operation; 'filesActedUpon', 'errors', and 'warnings' summarize the outcome. These last three values are the return values from the operation in DFOperations' corresponding to 'op' (applied to 'dfFile'). No 'response' is expected.
END.