ComputeServerActiveServicesImpl.mesa
The Compute Server side of the Summoner. MONITOR to maintain the state of the active services.
Last Edited by: Bob Hagmann, May 13, 1985 3:43:48 pm PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
DIRECTORY
Basics,
BasicTime,
Commander,
ComputeServerClient,
ComputeServer,
ComputeServerControl,
ComputeServerDebugger,
ComputeServerInternal,
InterpreterToolPrivate,
IO,
PrincOps,
PupDefs,
PupErrors,
PupTypes;
ComputeServerActiveServicesImpl:
CEDAR
MONITOR
IMPORTS BasicTime, ComputeServerInternal, PupErrors
EXPORTS ComputeServerInternal
= BEGIN
Variable Declarations
STREAM: TYPE = IO.STREAM;
ActiveServicesItem: TYPE = ComputeServerInternal.ActiveServicesItem;
ActiveServicesListBase: PUBLIC ComputeServerInternal.ActiveServicesItem ← NIL;
ActiveServicesItemObject: TYPE = ComputeServerInternal.ActiveServicesItemObject;
PupListener: TYPE = REF ComputeServerInternal.PupListenerObject;
Active Services List Maintence
AddPupAddress:
PUBLIC
ENTRY
PROC [serverPupAddress: PupDefs.PupAddress, procHandle: ComputeServerInternal.RegisteredProcHandle, listener: PupListener]
RETURNS [newItem: ActiveServicesItem] = {
newItem ← NEW[ActiveServicesItemObject ← [next: ActiveServicesListBase, listenerPupAddress: serverPupAddress, listener: listener, startListenGMT: BasicTime.Now[], procHandle: procHandle, success: true]];
ActiveServicesListBase ← newItem;
};
MatchPupAddress:
PUBLIC
ENTRY
PROC [serverPupAddress: PupDefs.PupAddress, flagStarted:
BOOL]
RETURNS [found:
BOOL, item: ActiveServicesItem] = {
nowItem: ActiveServicesItem ← ActiveServicesListBase ;
WHILE nowItem #
NIL
DO
IF serverPupAddress = nowItem.listenerPupAddress
THEN
{
IF flagStarted THEN nowItem.heardDoService ← TRUE;
RETURN [TRUE, nowItem];
};
nowItem ← nowItem.next;
ENDLOOP;
RETURN[FALSE, NIL];
};
findDebuggerItemFromInterpreterHandle:
PUBLIC
ENTRY
PROC [h: InterpreterToolPrivate.Handle]
RETURNS [found:
BOOL, item: ActiveServicesItem ←
NIL] = {
nowItem: ActiveServicesItem ← ActiveServicesListBase ;
WHILE nowItem #
NIL
DO
IF h = nowItem.h THEN RETURN [TRUE, nowItem];
nowItem ← nowItem.next;
ENDLOOP;
RETURN[FALSE, NIL];
};
KillOldUnstartedServices:
PUBLIC
PROC
= {
nowItem: ActiveServicesItem ← ActiveServicesListBase ;
lastItem: ActiveServicesItem ← NIL;
now: BasicTime.GMT ← BasicTime.Now[];
WHILE nowItem #
NIL
DO
IF ~nowItem.heardDoService
AND BasicTime.Period[nowItem.startListenGMT, now] > 77
THEN {
IF nowItem.listener # NIL THEN ComputeServerInternal.DestroyPupListener[nowItem.listener];
nowItem.listener ← NIL;
IF lastItem = NIL THEN ActiveServicesListBase ← nowItem.next
ELSE lastItem.next ← nowItem.next;
};
lastItem ← nowItem;
nowItem ← nowItem.next;
ENDLOOP;
};
DeletePupAddress:
PUBLIC
ENTRY
PROC [serverPupAddress: PupDefs.PupAddress]
RETURNS [found:
BOOL] = {
nowItem: ActiveServicesItem ← ActiveServicesListBase ;
lastItem: ActiveServicesItem ← NIL;
WHILE nowItem #
NIL
DO
IF serverPupAddress = nowItem.listenerPupAddress
THEN {
IF nowItem.listener # NIL THEN ComputeServerInternal.DestroyPupListener[nowItem.listener];
nowItem.listener ← NIL;
IF lastItem = NIL THEN ActiveServicesListBase ← nowItem.next
ELSE lastItem.next ← nowItem.next;
RETURN[TRUE];
};
lastItem ← nowItem;
nowItem ← nowItem.next;
ENDLOOP;
RETURN[FALSE];
};