XlPrivateResources.mesa
Copyright Ó 1989, 1990, 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, August 15, 1989 10:19:14 am PDT
Christian Jacobi, August 19, 1992 3:15 pm PDT
DIRECTORY Xl;
XlPrivateResources: CEDAR DEFINITIONS
SHARES Xl
~ BEGIN OPEN Xl;
Private interface for the implementation of Xl dealing with resource allocations
InitPrivateResources: PRIVATE PROC [c: Connection, resourceIdBase, resourceIdMask: CARD32];
Initializes the data structures dealing with resources
Call once per connection
resourceIdBase and resourceIdMask as from connection set up
MarkDead: PRIVATE PROC [c: Connection];
Frees up memory; call when connection dies
Resource creation, free and reuse
Freeing and re-use is necessary as the X window spec does not really guarantee enough resource id's for long lived, shared connections.
NewResourceID: --INTERNAL-- PROC [c: Connection] RETURNS [ID];
Returns a new or recycled ID
Call from inside c's monitor lock only
InternalFreeResourceID: PRIVATE --INTERNAL-- PROC [c: Connection, id: ID];
Recycle this ID
Call from inside c's monitor lock only
EntryFreeResourceID: PRIVATE --ENTRY-- PROC [c: Connection, id: ID];
Recycle this ID
Call from outside c's monitor lock only
ValidID: PROC [c: Connection, id: ID] RETURNS [BOOL];
Returns whether id looks like an id which could be owned by c
Resource reservation convention
This Convention is frequently used to declare cached and shared id's immutable.
Convention: Use of attached ref restricted to caller of NewResourceID. Restrict attachment to applications which will give a guarantee for detach on free, as there is no automatic built in detach.
Attach: PROC [c: Connection, id: ID, ref: REF];
Attaches a ref to an id.
Note: Do not forget to call Detach before freeing resource.
Detach: PROC [c: Connection, id: ID];
Undo of Attach.
Fetch: PROC [c: Connection, id: ID] RETURNS [ref: REF];
Fetches attached ref
END.