FinalizeOps.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, July 17, 1992 1:45:01 pm PDT
Christian Jacobi, July 22, 1992 10:44 am PDT
Access to Finalize using fewer resources.
All FinalizeOps clients are sharing a single Finalize.FinalizationQueue.
Threads are allocated only while needed.
DIRECTORY
Finalize USING [FinalizationState, Handle],
Process USING [Priority, priorityForeground];
FinalizeOps: CEDAR DEFINITIONS
~ BEGIN
Handle: TYPE = Finalize.Handle;
A "disguised" REF to an object
Compatible with Finalize.Handle, except:
The clientData field is used by FinalizeOpsImpl; it is not useful for clients of FinalizeOps.
IsFinalizeOpsHandle: PROC [handle: Finalize.Handle] RETURNS [BOOL];
Returns whether handle has been created with FinalizeOps
FinalizeProc: TYPE = PROC [handle: Handle, object: REF];
Type for procedure called to do finalization on handle.
object is Finalize.HandleToObject[handle], pre-computed for conveniance.
CallQueue: TYPE = REF CallQueueRep;
Represents a queue, thread, and a FinalizeProc procedure removing objects from the queue and finalizing them.
CallQueueRep: TYPE;
IsCallQueue: PROC [x: REF] RETURNS [BOOL];
Like ISTYPE[x, CallQueue]
NarrowCallQueue: PROC [x: REF] RETURNS [CallQueue];
Like NARROW[x, CallQueue]
EnableFinalization: PROC [object: REF, callQueue: CallQueue] RETURNS [handle: Handle];
Register object for finalization, returning a handle in enabled state.
ReenableFinalization: PROC [handle: Handle] RETURNS [oldState: Finalize.FinalizationState];
Reenable finalization for handle, returning its previous finalization state.
If handle was on the FinalizationQueue but not yet in the CallQueue, this removes it from the FinalizationQueue. oldState = disabled would not reflect whether a FinalizeProc has already been called or not. Clients which need this information reliably must keep track of it themselves in the FinalizeProc (and use a monitor of their own).
Restriction: handle must have been created with FinalizeOps.EnableFinalization.
CreateCallQueue: PROC [finalize: FinalizeProc, priority: Process.Priority ¬ Process.priorityForeground] RETURNS [CallQueue];
Creates a new queue; "finalize" will be called using "priority" to finalize objects.
END.