Register:
PUBLIC
ENTRY PROC
[key:
ROPE, version:
ROPE ←
NIL, proc: Commander.CommandProc, doc:
ROPE ←
NIL, clientData:
REF
ANY ←
NIL] = {
found: BOOL;
val: REF ANY;
IF key.IsEmpty[] THEN RETURN;
IF realRegister # NIL THEN realRegister[key, version, proc, doc, clientData];
IF proc =
NIL
THEN [] ← SymTab.Delete[x: Registry, key: key]
ELSE {
regList: LIST OF ComputeServerServer.RegisteredProcHandle;
regProc: ComputeServerServer.RegisteredProcHandle ← NEW[ComputeServerServer.RegisteredProcObject ← [version: version, service: key, commanderProcHandle: NEW[Commander.CommandProcObject ← [proc: proc, doc: doc, clientData: clientData]]]];
[found: found, val: val] ← SymTab.Fetch[x: Registry, key: key];
regList ← NARROW[val];
regList ← CONS[regProc, regList];
[] ← SymTab.Store[
x: Registry,
key: key,
val: regList
];
};
};
Enumerate:
PUBLIC
ENTRY
PROC [matchProc: ComputeServerServer.EnumerateAction]
RETURNS [key:
ROPE, procData:
LIST
OF ComputeServerServer.RegisteredProcHandle] = {
outerKey: ROPE;
outerProcData: LIST OF ComputeServerServer.RegisteredProcHandle;
EachPairProc: SymTab.EachPairAction = {
outerProcData ← NARROW[val];
outerKey ← key;
RETURN[matchProc[key: outerKey, procData: outerProcData]];
};
IF
NOT SymTab.Pairs[x: Registry, action: EachPairProc]
THEN {
outerKey ← NIL;
outerProcData ← NIL;
};
RETURN[key: outerKey, procData: outerProcData];
};
Lookup:
PUBLIC
PROC [key:
ROPE, version:
ROPE]
RETURNS [procData: ComputeServerServer.RegisteredProcHandle] = {
procRef: REF ANY;
found: BOOL;
listOfRegisteredProc: LIST OF ComputeServerServer.RegisteredProcHandle;
[found: found, val: procRef] ← SymTab.Fetch[x: Registry, key: key];
IF found
AND procRef #
NIL THEN {
loopList: LIST OF ComputeServerServer.RegisteredProcHandle;
listOfRegisteredProc ← NARROW[procRef];
FOR loopList ← listOfRegisteredProc, loopList.rest
UNTIL loopList =
NIL
DO
IF Rope.InlineIsEmpty[loopList.first.version] OR Rope.Equal[loopList.first.version, version, FALSE] THEN RETURN[loopList.first];
ENDLOOP;
}
ELSE procData ← NIL;
};