WalnutRegistry.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Donahue, July 9, 1985 12:51:15 pm PDT
Willie-Sue, December 29, 1986 5:51:20 pm PST
Walnut Registry provides notification to outside clients of changes in Walnut databases. Walnut RegistryImpl can be run without running Walnut -- WalnutKernel imports it, rather than the other way around.
Procedures registered with Walnut Registry are placed on the queue, using MBQueue.QueueClientAction, given in the registration when the database changes; clients are guaranteed that the procedures will be queued in the order in which the database changes that caused their invocation occurred.
WalnutRegistry:
CEDAR
DEFINITIONS =
BEGIN
WalnutState:
TYPE = {unknown, initializing, active, stopped};
unknown means that Walnut has not notified the registry yet, initializing that Walnut is the process of getting itself started.
Event: TYPE = {unknown, initializing, started, stopped, mailRead, expungeComplete};
EventProc: TYPE = PROC[event: Event, clientData: REF ANY];
MsgEvent: TYPE = {firstRead, deleted, unDeleted};
MsgProc: TYPE = PROC[msgName: Rope.ROPE, event: MsgEvent, clientData: REF ANY];
MsgGroup: TYPE = ARRAY[0..MsgGroupSize) OF Rope.ROPE;
MsgGroupSize: CARDINAL = 20;
MsgGroupEvent: TYPE = {added, destroyed};
MsgGroupProc:
TYPE =
PROC[
msgGroup: REF MsgGroup, event: MsgGroupEvent, clientData: REF ANY];
MsgSetEvent: TYPE = {created, destroyed};
MsgSetProc: TYPE = PROC[msgSetName: Rope.ROPE, event: MsgSetEvent, clientData: REF ANY];
MoveProc:
TYPE =
PROC[
msgName: Rope.ROPE, fromMsgSet, toMsgSet: Rope.ROPE, clientData: REF ANY];
ProcSet:
TYPE =
RECORD[eventProc: EventProc ¬ NIL,
eventProcData: REF ANY ¬ NIL,
msgProc: MsgProc ¬ NIL,
msgProcData: REF ANY ¬ NIL,
msgGroupProc: MsgGroupProc ¬ NIL,
msgGroupData: REF ANY ¬ NIL,
msgSetProc: MsgSetProc ¬ NIL,
msgSetData: REF ANY ¬ NIL,
moveProc: MoveProc ¬ NIL,
moveProcData: REF ANY ¬ NIL];
Registration: TYPE = REF;
Register:
PROC [procSet: ProcSet, queue: MBQueue.Queue]
RETURNS[registration: Registration];
Register a set of procedures to be invoked when the appropriate database changes occur. Return a registration that can be used to name the set
InvalidRegistration:
ERROR;
Each of the procedures below will raise this error if given a registration that does not currently exist in the table of registered procedures
UnRegister:
PROC [registration: Registration];
Remove the procedures named by the registration
GetProcs:
PROC[registration: Registration]
RETURNS[procSet: ProcSet, queue: MBQueue.Queue];
Return the procedures named by the registration
CurrentWalnutState:
PROC
RETURNS[walnutState: WalnutState];
a quick and safe way to find out if Walnut has been loaded and if it is active or not
END.