The Trunk: Kernel-eem.970.mcz

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

The Trunk: Kernel-eem.970.mcz

commits-2
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.970.mcz

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

Name: Kernel-eem.970
Author: eem
Time: 5 January 2016, 11:48:28.872258 am
UUID: 95e73746-6557-49a2-af25-ce39009a57b0
Ancestors: Kernel-eem.969

Changes to Time and Delay prior to changing over to the utc microsecond clock and its use in delay scheduling.

=============== Diff against Kernel-eem.969 ===============

Item was changed:
  SharedPool subclass: #ChronologyConstants
  instanceVariableNames: 'seconds offset jdn nanos'
+ classVariableNames: 'DayNames DaysInMonth MicrosecondsInDay MonthNames NanosInMillisecond NanosInSecond OneDay SecondsInDay SecondsInHour SecondsInMinute SqueakEpoch Zero'
- classVariableNames: 'DayNames DaysInMonth MonthNames NanosInMillisecond NanosInSecond OneDay SecondsInDay SecondsInHour SecondsInMinute SqueakEpoch Zero'
  poolDictionaries: ''
  category: 'Kernel-Chronology'!
 
  !ChronologyConstants commentStamp: 'brp 3/12/2004 14:34' prior: 0!
  ChronologyConstants is a SharedPool for the constants used by the Kernel-Chronology classes.!

Item was changed:
  ----- Method: ChronologyConstants class>>initialize (in category 'class initialization') -----
  initialize
  "ChronologyConstants initialize"
 
  SqueakEpoch := 2415386. "Julian day number of 1 Jan 1901"
  SecondsInDay := 86400.
  SecondsInHour := 3600.
  SecondsInMinute := 60.
+ MicrosecondsInDay := 24 * 60 * 60 * 1000000.
  NanosInSecond := 10 raisedTo: 9.
  NanosInMillisecond := 10 raisedTo: 6.
  DayNames := #(Sunday Monday Tuesday Wednesday Thursday Friday Saturday).
 
+ MonthNames := #( January February March April May June
+ July August September October November December).
+ DaysInMonth := #(31 28 31 30 31 30 31 31 30 31 30 31)!
- MonthNames := #(January February March April May June July
-   August September October November December).
- DaysInMonth := #(31 28 31 30 31 30 31 31 30 31 30 31)
- !

Item was changed:
  ----- Method: DateAndTime class>>nowWithOffset: (in category 'squeak protocol') -----
  nowWithOffset: aDuration
+ | usecs |
+ usecs := Time utcMicrosecondClock.
+ ^self basicNew
+ setJdn: DaysSinceEpoch
+ seconds: usecs // 1000000 \\ SecondsInDay
+ nano: usecs \\ 1000000 * 1000
+ offset: aDuration!
- | nanoTicks msm |
- nanoTicks := (msm := self milliSecondsSinceMidnight) * 1000000.
- "The following usually only executes at system startup."
- ^ LastTick < nanoTicks
- ifTrue:
- [ LastTick := nanoTicks.
- self waitForOffsets.
- self basicNew
- setJdn: DaysSinceEpoch
- seconds: msm // 1000
- nano: msm \\ 1000 * 1000000
- offset: aDuration ]
- ifFalse:
- [ LastTickSemaphore critical:
- [ LastTick := LastTick + 1.
- self waitForOffsets.
- self basicNew
- setJdn: DaysSinceEpoch
- seconds: LastTick // 1000000000
- nano: LastTick \\ 1000000000
- offset: aDuration ] ]
- "
- [ 10000 timesRepeat: [ self now. ] ] timeToRun / 10000.0 .
-
- If calls to DateAndTime-c-#now are within a single millisecond the semaphore code
- to ensure that (self now <= self now) slows things down considerably by a factor of about 20.
-
- The actual speed of a single call to DateAndTime-now in milliseconds is
- demonstrated by the unguarded method below.
-
- [ 100000 timesRepeat: [ self todayAtMilliSeconds: (self milliSecondsSinceMidnight) ] ] timeToRun / 100000.0 .  0.00494 0.00481 0.00492 0.00495
-  
- "!

Item was added:
+ ----- Method: Delay class>>primSignal:atUTCMicroseconds: (in category 'primitives') -----
+ primSignal: aSemaphore atUTCMicroseconds: anInteger
+ "Signal the semaphore when the UTC microsecond clock reaches the value of the second argument.
+ Fail if the first argument is neither a Semaphore nor nil, or if the second argument is not an integer.
+ Essential. See Object documentation whatIsAPrimitive."
+ <primitive: 242>
+ ^self primitiveFailed!

Item was added:
+ ----- Method: Delay class>>scheduleDelay:from: (in category 'timer process') -----
+ scheduleDelay: aDelay from: nowUsecs
+ "Private. Schedule this Delay."
+
+ aDelay
+ resumptionTime: nowUsecs + aDelay microsecondDelayDuration;
+ beingWaitedOn: true.
+ ActiveDelay
+ ifNil: [ActiveDelay := aDelay]
+ ifNotNil:
+ [aDelay resumptionTime < ActiveDelay resumptionTime
+ ifTrue: [SuspendedDelays add: ActiveDelay.
+ ActiveDelay := aDelay]
+ ifFalse: [SuspendedDelays add: aDelay]]!

Item was changed:
  ----- Method: Delay>>delayDuration (in category 'public') -----
  delayDuration
+ "Answer the receiver's duration in milliseconds."
  ^delayDuration!

Item was changed:
  ----- Method: Delay>>delayDuration: (in category 'public') -----
+ delayDuration: milliseconds
+ "Set teh receiver's duration in milliseconds, iff it is not active."
+ milliseconds < 0 ifTrue:
+ [self error: 'Delay times cannot be negative!!'].
+ beingWaitedOn == true ifTrue:
+ [self error: 'This delay is scheduled!!'].
+ delayDuration := milliseconds asInteger!
- delayDuration: anInteger
-
- anInteger < 0 ifTrue: [ self error: 'Delay times cannot be negative!!' ].
- beingWaitedOn == true ifTrue: [ self error: 'This delay is scheduled!!' ].
- delayDuration := anInteger!

Item was added:
+ ----- Method: Delay>>microsecondDelayDuration (in category 'public') -----
+ microsecondDelayDuration
+ "Answer the receiver's duration in microseconds."
+ ^delayDuration * 1000!

Item was removed:
- ----- Method: Delay>>scheduleEvent (in category 'private') -----
- scheduleEvent
- "Schedule this delay"
- resumptionTime := Time millisecondClockValue + delayDuration.
- AccessProtect critical:[
- ScheduledDelay := self.
- TimingSemaphore signal.
- ].!

Item was added:
+ ----- Method: Time class>>localMicrosecondClock (in category 'clock') -----
+ localMicrosecondClock
+ "Answer the number of microseconds since the start of the 20th century in local time."
+ <primitive: 241>
+ ^0!

Item was changed:
  ----- Method: Time class>>now (in category 'ansi protocol') -----
  now
  "Answer a Time representing the time right now - this is a 24 hour clock."
+ | localUsecs localUsecsToday |
+ localUsecs := self localMicrosecondClock.
+ localUsecsToday := localUsecs \\ MicrosecondsInDay.
+ ^ self
+ seconds: localUsecsToday // 1000000
+ nanoSeconds: localUsecsToday \\ 1000000 * 1000!
-
- | ms |
-
- ms := self milliSecondsSinceMidnight.
-
- ^ self seconds:  (ms // 1000) nanoSeconds: (ms \\ 1000) * 1000000
-
-
- !

Item was added:
+ ----- Method: Time class>>utcMicrosecondClock (in category 'clock') -----
+ utcMicrosecondClock
+ "Answer the number of microseconds since the start of the 20th century in UTC."
+ <primitive: 240>
+ ^0!