DFOperationsQueue.mesa
last edited by Levin on December 6, 1983 9:22 am
DIRECTORY
DFOperations USING [BringOverAction, BringOverFilter, InteractionProc, SModelAction],
IO USING [STREAM],
Process USING [Priority, priorityBackground],
Rope USING [ROPE];
DFOperationsQueue: CEDAR DEFINITIONS =
BEGIN
OPEN Ops: DFOperations;
ROPE: TYPE = Rope.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: Ops.InteractionProc,
log: IO.STREAM,
clientData: REF ANY,
opSpecific: SELECT op: RequestedOp FROM
bringOver => [filter: Ops.BringOverFilter, action: Ops.BringOverAction],
sModel => [action: Ops.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 ANYNIL]
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.