<> <> <> DIRECTORY Process USING [DisableAborts, DisableTimeout, EnableAborts, Milliseconds, MsecToTicks, SetTimeout]; Synchronizer: CEDAR DEFINITIONS LOCKS sync USING sync: Synchronizer IMPORTS Process = BEGIN <<>> <> maximumLapse: Process.Milliseconds = LAST[Process.Milliseconds]; <> Synchronizer: TYPE = REF SynchronizerRep; SynchronizerRep: TYPE = MONITORED RECORD [condition: CONDITION, count: CARDINAL]; <> Initialize: ENTRY PROCEDURE [sync: Synchronizer, enableAbort, enableTimeout: BOOLEAN, lapse: Process.Milliseconds _ maximumLapse] = TRUSTED INLINE BEGIN ENABLE UNWIND => NULL; IF enableAbort THEN Process.EnableAborts[pCondition: @sync.condition] ELSE Process.DisableAborts[pCondition: @sync.condition]; IF enableTimeout THEN Process.SetTimeout[condition: @sync.condition, ticks: Process.MsecToTicks[lapse]] ELSE Process.DisableTimeout[condition: @sync.condition]; sync.count _ 0; END; Broadcast: ENTRY PROCEDURE [sync: Synchronizer] = INLINE BEGIN ENABLE UNWIND => NULL; sync.count _ sync.count + 1; BROADCAST sync.condition; END; ForceTimeout: ENTRY PROCEDURE [sync: Synchronizer] = INLINE BEGIN ENABLE UNWIND => NULL; BROADCAST sync.condition; END; Notify: ENTRY PROCEDURE [sync: Synchronizer] = INLINE BEGIN ENABLE UNWIND => NULL; sync.count _ sync.count + 1; NOTIFY sync.condition; END; Wait: ENTRY PROCEDURE [sync: Synchronizer] RETURNS [timeout: BOOLEAN] = INLINE BEGIN ENABLE UNWIND => NULL; localCount: CARDINAL _ sync.count; WAIT sync.condition; RETURN[timeout: localCount = sync.count]; END; END.