ComputeServerServerStubImpl.mesa
The Compute Server side of the Summoner.
Last Edited by: Bob Hagmann, May 15, 1985 7:47:33 am PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
DIRECTORY
Commander,
ComputeServerServer,
SymTab,
Rope;
ComputeServerServerStubImpl: CEDAR MONITOR
IMPORTS Rope, SymTab
EXPORTS ComputeServerServer
= BEGIN
Variable Declarations
ROPE: TYPE = Rope.ROPE;
Registry: PUBLIC SymTab.Ref; -- registered commands, for software that has been run and did a ComputeServer.Register, are saved here
realRegister: PROC [key: ROPE, version: ROPENIL, proc: Commander.CommandProc, doc: ROPENIL, clientData: REF ANYNIL] ← NIL;
Command Registry
Register: PUBLIC ENTRY PROC [key: ROPE, version: ROPENIL, proc: Commander.CommandProc, doc: ROPENIL, clientData: REF ANYNIL] = {
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;
};
Registry of the real Registration
RegisterRealRegistration: PUBLIC PROC [Register: PROC [key: ROPE, version: ROPENIL, proc: Commander.CommandProc, doc: ROPENIL, clientData: REF ANYNIL]] = {
realRegister ← Register;
};
Initialization
Registry ← SymTab.Create[mod: 59, case: FALSE];
END.
Bob Hagmann February 12, 1985 2:09:54 pm PST
changes to: DoService