<> <> <> <<>> DIRECTORY Graph USING [GraphHandle, GraphProc], GraphOps, GraphPrivate USING [GraphAtomProc, GraphPlaceProc], GraphUtil USING [BlinkMsg, HandleNotNil], Process USING [SecondsToTicks, SetTimeout]; GraphMonitor: CEDAR MONITOR IMPORTS GraphUtil, Process EXPORTS GraphOps, GraphPrivate = { OPEN Graph, GraphPrivate, GraphUtil; timeOut: CONDITION; Lock: PUBLIC ENTRY GraphProc = { ENABLE UNWIND => NULL; IF HandleNotNil[handle] THEN { WHILE handle.locked DO WAIT handle.unlocked; ENDLOOP; handle.locked _ TRUE; }; }; -- Lock Unlock: PUBLIC ENTRY GraphProc = { ENABLE UNWIND => NULL; IF HandleNotNil[handle] THEN { handle.locked _ FALSE; BROADCAST handle.unlocked; }; }; -- Unlock IsLocked: PUBLIC ENTRY PROC [handle: GraphHandle _ NIL] RETURNS [BOOL] = { IF handle = NIL THEN RETURN[FALSE] ELSE RETURN[handle.locked]; }; -- IsLocked CallWithLock: PUBLIC PROC [handle: GraphHandle _ NIL, proc: GraphProc] = {IF HandleNotNil[handle] AND proc # NIL THEN {Lock[handle]; proc[handle]; Unlock[handle]}}; -- CallWithLock LockedPlaceProc: PUBLIC PROC [handle: GraphHandle _ NIL, sx, sy: INTEGER _ 0, proc: GraphPlaceProc _ NIL] = { lockedProc: GraphProc = {proc[handle, sx, sy]}; CallWithLock[handle, lockedProc]; }; -- LockedPlaceProc LockedAtomProc: PUBLIC PROC [handle: GraphHandle _ NIL, atom: ATOM, proc: GraphAtomProc _ NIL] = { lockedProc: GraphProc = {proc[handle, atom]}; CallWithLock[handle, lockedProc]; }; -- LockedAtomProc Wait: PUBLIC ENTRY PROC = { -- wait a second. WAIT timeOut; }; UserEditAllowed: PUBLIC ENTRY PROC [handle: GraphHandle _ NIL] RETURNS [BOOL] = { IF HandleNotNil[handle] THEN { OPEN handle; IF userEditAllowed THEN RETURN [TRUE] ELSE { BlinkMsg["Graph is currently controlled by a program. Please wait till it finishes to do this."]; RETURN [FALSE]; }; } ELSE RETURN [FALSE]; }; -- UserEditAllowed Init: PROC = TRUSTED { Process.SetTimeout[@timeOut, Process.SecondsToTicks[1]]; }; Init[]; }. CHANGE LOG. SChen, create at October 9, 1985 6:46:56 pm PDT.