File Synchronizer.mesa
Copyright Ó Xerox Corporation 1981, 1982, 1983, 1984, 1985, 1986, 1987. All rights reserved.
Last edited by Strickberger 29-Nov-84 16:47:32
Tim Diebert: January 6, 1987 2:39:43 pm PST
DIRECTORY
Process USING [DisableAborts, DisableTimeout, EnableAborts, Milliseconds, MsecToTicks, SetTimeout];
Synchronizer:
DEFINITIONS
LOCKS synchronizer
USING synchronizer: Handle
IMPORTS Process = BEGIN
Constants:
maximumLapse: Process.Milliseconds = LAST[Process.Milliseconds];
Handle: TYPE = LONG POINTER TO Object;
Object: TYPE = MONITORED RECORD [condition: CONDITION, count: CARDINAL];
Initialize:
ENTRY
PROCEDURE [synchronizer: Handle, enableAbort, enableTimeout:
BOOLEAN, lapse: Process.Milliseconds ← maximumLapse] =
TRUSTED
INLINE
BEGIN
ENABLE UNWIND => NULL;
IF enableAbort
THEN Process.EnableAborts[pCondition: @synchronizer.condition]
ELSE Process.DisableAborts[pCondition: @synchronizer.condition];
IF enableTimeout
THEN Process.SetTimeout[condition: @synchronizer.condition,
ticks: Process.MsecToTicks[lapse]]
ELSE Process.DisableTimeout[condition: @synchronizer.condition];
synchronizer.count ← 0;
END;
Broadcast:
ENTRY
PROCEDURE [synchronizer: Handle] =
INLINE
BEGIN
ENABLE UNWIND => NULL;
synchronizer.count ← synchronizer.count + 1;
BROADCAST synchronizer.condition;
END;
ForceTimeout:
ENTRY
PROCEDURE [synchronizer: Handle] =
INLINE
BEGIN
ENABLE UNWIND => NULL;
BROADCAST synchronizer.condition;
END;
Notify:
ENTRY
PROCEDURE [synchronizer: Handle] =
INLINE
BEGIN
ENABLE UNWIND => NULL;
synchronizer.count ← synchronizer.count + 1;
NOTIFY synchronizer.condition;
END;
Wait:
ENTRY
PROCEDURE [synchronizer: Handle]
RETURNS [timeout:
BOOLEAN] =
INLINE
BEGIN
ENABLE UNWIND => NULL;
localCount: CARDINAL ← synchronizer.count;
WAIT synchronizer.condition;
RETURN[timeout: localCount = synchronizer.count];
END;
END.
LOG
When / Who / What.
81/Claude Pany/Created.
11-Apr-83 15:23:16 - Trowell - created SynchronizerImpl and removed INLINEs here for Sierra compiler bug workaround
10-Oct-83 3:30:32 - Strickberger - Restored INLINEs and deleted Impl. POINTER ← LONG POINTER for Klamath.
29-Nov-84 16:47:32 - Strickberger - Modified to allow multiple Waits to return timeout correctly. Add ForceTimeout. Add copyright.
19-Jul-85 1:25:43 - Strickberger - FixArrows.
Tim Diebert: September 8, 1986 4:00:58 pm PDT
Convert to Cedar