The Trunk: Morphic-ul.1151.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-ul.1151.mcz

commits-2
Levente Uzonyi uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ul.1151.mcz

==================== Summary ====================

Name: Morphic-ul.1151
Author: ul
Time: 31 May 2016, 1:05:09.648151 am
UUID: 88bc6d22-477b-477f-8aa9-b324ff0dbcd0
Ancestors: Morphic-mt.1150

Make MorphicAlarmQueue not be a subclass of Heap. Use encapsulation instead. Part #1.

=============== Diff against Morphic-mt.1150 ===============

Item was changed:
  Heap subclass: #MorphicAlarmQueue
+ instanceVariableNames: 'mutex sequenceNumber heap'
- instanceVariableNames: 'mutex sequenceNumber'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Morphic-Events'!
 
  !MorphicAlarmQueue commentStamp: 'jcg 1/9/2010 13:34' prior: 0!
  MorphicAlarmQueue is a specialized Heap.  The main change is to stamp each added MorphicAlarm with a sequence number to ensure that alarms scheduled for the same time are executed in the order that they were added.!

Item was changed:
  ----- Method: MorphicAlarmQueue>>add: (in category 'adding') -----
  add: aMorphicAlarm
+
+ heap ifNotNil: [
+ aMorphicAlarm sequenceNumber: self nextSequenceNumber.
+ ^heap add: aMorphicAlarm ].
  (sequenceNumber := sequenceNumber + 1) = 16r3FFFFFFF ifTrue: [
  "Sequence number overflow... reassign sequence numbers starting at 0."
  | alarmList |
  alarmList := self asArray sort: [:msg1 :msg2 |
  msg1 sequenceNumber < msg2 sequenceNumber
  ].
  alarmList withIndexDo: [:msg :ind | msg sequenceNumber: ind-1].
  "The #bitAnd: for the unlikely event that we have > 16r3FFFFFF messages in the queue."
  sequenceNumber := alarmList last sequenceNumber + 1 bitAnd: 16r3FFFFFFF.
  ].
  aMorphicAlarm sequenceNumber: sequenceNumber.
  super add: aMorphicAlarm.
 
  "If we doubt our sanity..."
  false ifTrue: [
  self isValidHeap ifFalse: [self error: 'not a valid heap!!!!!!'].
  ].
  ^aMorphicAlarm!

Item was added:
+ ----- Method: MorphicAlarmQueue>>detect:ifNone: (in category 'migration') -----
+ detect: aBlock ifNone: noneBlock
+
+ heap ifNil: [ ^super detect: aBlock ifNone: noneBlock ].
+ ^heap detect: aBlock ifNone: noneBlock!

Item was added:
+ ----- Method: MorphicAlarmQueue>>do: (in category 'migration') -----
+ do: aBlock
+
+ heap ifNil: [ ^super do: aBlock ].
+ ^heap do: aBlock!

Item was added:
+ ----- Method: MorphicAlarmQueue>>first (in category 'migration') -----
+ first
+
+ heap ifNil: [ ^super first ].
+ ^heap first!

Item was changed:
  ----- Method: MorphicAlarmQueue>>initialize (in category 'initialize') -----
  initialize
+
  super initialize.
+ sequenceNumber := 0.
+ heap := Heap sortBlock: [ :alarmA :alarmB |
+ alarmA scheduledTime = alarmB scheduledTime
+ ifFalse: [ alarmA scheduledTime < alarmB scheduledTime ]
+ ifTrue: [
+ alarmA sequenceNumber = alarmB sequenceNumber
+ ifFalse: [ alarmA sequenceNumber < alarmB sequenceNumber ]
+ ifTrue: [ self error: 'These alarms run at the same time' ] ] ]!
- sequenceNumber := 0.!

Item was added:
+ ----- Method: MorphicAlarmQueue>>isEmpty (in category 'migration') -----
+ isEmpty
+
+ heap ifNil: [ ^super isEmpty ].
+ ^heap isEmpty!

Item was added:
+ ----- Method: MorphicAlarmQueue>>migrate (in category 'migration') -----
+ migrate
+
+ heap ifNotNil: [ ^self ].
+ heap := Heap withAll: self asArray sortBlock: [ :alarmA :alarmB |
+ alarmA scheduledTime = alarmB scheduledTime
+ ifFalse: [ alarmA scheduledTime < alarmB scheduledTime ]
+ ifTrue: [
+ alarmA sequenceNumber = alarmB sequenceNumber
+ ifFalse: [ alarmA sequenceNumber < alarmB sequenceNumber ]
+ ifTrue: [ self error: 'These alarms run at the same time' ] ] ]!

Item was added:
+ ----- Method: MorphicAlarmQueue>>nextSequenceNumber (in category 'private') -----
+ nextSequenceNumber
+
+ (sequenceNumber := sequenceNumber + 1) = 16r3FFFFFFF ifTrue: [
+ "Sequence number overflow... reassign sequence numbers starting at 1."
+ | alarmList |
+ alarmList := heap fullySort asArray.
+ alarmList withIndexDo: [ :alarm :index |
+ alarm sequenceNumber: index ].
+ sequenceNumber := alarmList size + 1 ].
+ ^sequenceNumber!

Item was added:
+ ----- Method: MorphicAlarmQueue>>postCopy (in category 'as yet unclassified') -----
+ postCopy
+
+ super postCopy.
+ heap := heap copy!

Item was added:
+ ----- Method: MorphicAlarmQueue>>remove: (in category 'migration') -----
+ remove: anObject
+
+ heap ifNil: [ ^super remove: anObject ].
+ ^heap remove: anObject!

Item was added:
+ ----- Method: MorphicAlarmQueue>>removeFirst (in category 'migration') -----
+ removeFirst
+
+ heap ifNil: [ ^super removeFirst ].
+ ^heap removeFirst!

Item was changed:
+ (PackageInfo named: 'Morphic') postscript: 'MorphicAlarmQueue allInstancesDo: #migrate'!
- (PackageInfo named: 'Morphic') postscript: 'SystemWindow reconfigureWindowsForFocus.'!