[squeak-dev] The Trunk: Kernel-ul.893.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Jan 18 19:39:49 UTC 2015


Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.893.mcz

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

Name: Kernel-ul.893
Author: ul
Time: 18 January 2015, 8:23:34.326 pm
UUID: 349e7be8-30d6-41ce-a6cb-ad5490347eed
Ancestors: Kernel-ul.891, Kernel-nice.892

- Added Delay >> #delayDuration: which allows one to reuse the same Delay instance with a different duration.
- Merged Kernel-ul.891:
	- Introduced ThreadSafeRandom, a process-local variable holding a Random instance. Replaced all uses of Collection's RandomForPicking with ThreadSafeRandom value.
	- Faster Magnitude >> #between:and:.
	- Added an accessor for Semaphore's excessSignals variable.

=============== Diff against Kernel-nice.892 ===============

Item was added:
+ ----- Method: Delay>>delayDuration: (in category 'public') -----
+ 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 changed:
  ----- Method: Integer>>atRandom (in category 'truncation and round off') -----
  atRandom
+ 	"Answer a random integer from 1 to self.  This implementation uses the process-local random number generator."
- 	"Answer a random integer from 1 to self.  This implementation uses a
- 	shared generator. Heavy users should their own implementation or use
- 	Interval>atRandom: directly."
  
+ 	self isZero ifTrue: [ ^0 ].
+ 	self negative ifTrue: [ ^self negated atRandom negated ].
+ 	^self atRandom: ThreadSafeRandom value!
- 	self = 0 ifTrue: [ ^0 ].
- 	self < 0 ifTrue: [ ^self negated atRandom negated ].
- 	^Collection mutexForPicking critical: [
- 		self atRandom: Collection randomForPicking ]!

Item was changed:
  ----- Method: Magnitude>>between:and: (in category 'comparing') -----
  between: min and: max 
  	"Answer whether the receiver is less than or equal to the argument, max, 
  	and greater than or equal to the argument, min."
  
+ 	min <= self ifFalse: [ ^false ].
+ 	^self <= max!
- 	^self >= min and: [self <= max]!

Item was added:
+ ----- Method: Semaphore>>excessSignals (in category 'accessing') -----
+ excessSignals
+ 
+ 	^excessSignals!

Item was added:
+ ProcessLocalVariable subclass: #ThreadSafeRandom
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'Kernel-Numbers'!
+ 
+ !ThreadSafeRandom commentStamp: 'ul 12/17/2014 15:18' prior: 0!
+ I am a ProcessLocalVariable. I hold the an instance of Random for each process. If the process doesn't have such instance yet, then my class-side #default message will create one. The instance should not be shared among processes.
+ 
+ I implement all methods of Random's accessing category on the class side, and proxy them to the instance. If you want to use any other methods, or the object itself, then use #value directly.!

Item was added:
+ ----- Method: ThreadSafeRandom class>>default (in category 'accessing') -----
+ default
+ 
+ 	^self value: Random new!

Item was added:
+ ----- Method: ThreadSafeRandom class>>next (in category 'accessing') -----
+ next
+ 
+ 	^self value next!

Item was added:
+ ----- Method: ThreadSafeRandom class>>next: (in category 'accessing') -----
+ next: anInteger
+ 
+ 	^self value next: anInteger!

Item was added:
+ ----- Method: ThreadSafeRandom class>>next:into: (in category 'accessing') -----
+ next: anInteger into: anArray
+ 
+ 	^self value next: anInteger into: anArray!

Item was added:
+ ----- Method: ThreadSafeRandom class>>nextInt: (in category 'accessing') -----
+ nextInt: anInteger
+ 
+ 	^self value nextInt: anInteger!



More information about the Squeak-dev mailing list