Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 1 participants
- 144619 messages
[Pharo-project] Issue 3239 in pharo: CUIS added MessageTally default size tweaks
by pharo@googlecode.com
Status: Fixed
Owner: stephane.ducasse
Labels: Milestone-1.2 Type-Squeak Difficulty-Easy
New issue 3239 by stephane.ducasse: CUIS added MessageTally default size
tweaks
http://code.google.com/p/pharo/issues/detail?id=3239
Item was changed:
----- Method: MessageTally class>>defaultMaxClassNameSize (in
category 'defaults') -----
defaultMaxClassNameSize
"Return the default maximum width of the class name alone"
+ ^50!
- ^30!
Item was changed:
----- Method: MessageTally class>>defaultMaxClassPlusSelectorSize (in
category 'defaults') -----
defaultMaxClassPlusSelectorSize
"Return the default maximum width of the class plus selector
together (not counting the '>>')"
+ ^100!
- ^60!
Nov. 11, 2010
[Pharo-project] Issue 3238 in pharo: Use Class instead of TextDiffBuilder in changelist
by pharo@googlecode.com
Status: Accepted
Owner: stephane.ducasse
Labels: Type-Squeak
New issue 3238 by stephane.ducasse: Use Class instead of TextDiffBuilder in
changelist
http://code.google.com/p/pharo/issues/detail?id=3238
Should check how to invoke this method
- use ClassDiffBuilder for diffing class definitions and comments in
ChangeList
=============== Diff against Tools-ul.275 ===============
Item was changed:
----- Method: ChangeList>>contentsDiffedFromCurrent (in category 'viewing
access') -----
contentsDiffedFromCurrent
"Answer the contents diffed forward from current (in-memory) method
version"
| aChange aClass |
listIndex = 0
ifTrue: [^ ''].
aChange := changeList at: listIndex.
(aChange type == #method
and: [(aClass := aChange methodClass) notNil
and: [aClass includesSelector: aChange methodSelector]]) ifTrue:
[^Utilities
methodDiffFor: aChange text
class: aClass
selector: aChange methodSelector
prettyDiffs: self showingPrettyDiffs].
aChange type == #doIt ifTrue:
[| tokens |
tokens := Scanner new scanTokens: aChange string.
((tokens select:
[:substr| #(subclass: variableByteSubclass:
variableWordSubclass:
instanceVariableNames: classVariableNames: ) includes: substr])
asSet size >= 3
and: [(aClass := Smalltalk at: tokens third ifAbsent: [])
notNil
and: [aClass isBehavior]]) ifTrue:
+ [^ClassDiffBuilder buildDisplayPatchFrom: aClass
definition to: aChange string].
- [^TextDiffBuilder buildDisplayPatchFrom: aClass
definition to: aChange string].
(tokens size = 4
and: [tokens second == #class
and: [tokens third == #instanceVariableNames:
and: [(aClass := Smalltalk at: tokens first ifAbsent: [])
notNil
and: [aClass isBehavior]]]]) ifTrue:
+ [^ClassDiffBuilder buildDisplayPatchFrom: aClass
class definition to: aChange string]].
- [^TextDiffBuilder buildDisplayPatchFrom: aClass
class definition to: aChange string]].
(aChange type == #classComment
and: [(aClass := aChange commentClass) notNil]) ifTrue:
+ [^ClassDiffBuilder buildDisplayPatchFrom: aClass comment
asString to: aChange string].
- [^TextDiffBuilder buildDisplayPatchFrom: aClass comment
asString to: aChange string].
^(changeList at: listIndex) text!
Nov. 11, 2010
[Pharo-project] Issue 3237 in pharo: If MessageTally is not in memory
by pharo@googlecode.com
Status: FixedWaitingToBePharoed
Owner: stephane.ducasse
Labels: Type-Squeak
New issue 3237 by stephane.ducasse: If MessageTally is not in memory
http://code.google.com/p/pharo/issues/detail?id=3237
we have to compare because the implementation in pharo is different.
in pharo we do
Smalltalk globals at: #MessageTally ifPresent: [ :c | c new close ].
----- Method: Debugger>>process:controller:context: (in
category 'private') -----
process: aProcess controller: aController context: aContext
super initialize.
+ Smalltalk at: #MessageTally ifPresentAndInMemory: [ :tally |
+ tally terminateTimerProcess].
- Smalltalk at: #MessageTally ifPresent:[:tally| tally
terminateTimerProcess].
contents := nil.
interruptedProcess := aProcess.
interruptedController := aController.
contextStackTop := aContext.
self newStack: (contextStackTop stackOfSize: 1).
contextStackIndex := 1.
externalInterrupt := false.
selectingPC := true.
Smalltalk isMorphic ifTrue:
[errorWasInUIProcess := false]!
Nov. 11, 2010
Re: [Pharo-project] Issue 3236 in pharo: Cuis DateAndTime Enhancement
by pharo@googlecode.com
Updates:
Status: FixedWaitingToBePharoed
Comment #1 on issue 3236 by stephane.ducasse: Cuis DateAndTime Enhancement
http://code.google.com/p/pharo/issues/detail?id=3236
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.513.mcz
==================== Summary ====================
Name: Kernel-ul.513
Author: ul
Time: 7 November 2010, 12:08:10.875 am
UUID: 887f4907-c347-2e45-8d2e-dd7814ac4248
Ancestors: Kernel-ul.512
- DateAndTime startup enhancement from Cuis part 2
=============== Diff against Kernel-ul.512 ===============
Item was changed:
----- Method: DateAndTime class>>initializeOffsets (in
category 'initialize-release') -----
+ initializeOffsets
+ | durationSinceEpoch secondsSinceMidnight nowSecs |
+ LastTick := 0.
+ nowSecs := self clock secondsWhenClockTicks.
+ LastMilliSeconds := self millisecondClockValue.
+ durationSinceEpoch := Duration
+ days: SqueakEpoch
+ hours: 0
+ minutes: 0
+ seconds: nowSecs.
+ DaysSinceEpoch := durationSinceEpoch days.
+ secondsSinceMidnight := (durationSinceEpoch -
+ (Duration
+ days: DaysSinceEpoch
+ hours: 0
+ minutes: 0
+ seconds: 0)) asSeconds.
+ MilliSecondOffset := secondsSinceMidnight * 1000 - LastMilliSeconds!
- initializeOffsets
-
- | epochianSeconds secondsSinceMidnight nowSecs |
-
- LastTick := 0.
-
- nowSecs := self clock secondsWhenClockTicks.
- LastMilliSeconds := self millisecondClockValue.
-
- epochianSeconds := Duration days: SqueakEpoch hours: 0 minutes: 0
seconds: nowSecs.
-
- DaysSinceEpoch := epochianSeconds days.
-
- secondsSinceMidnight := (epochianSeconds - (Duration days:
DaysSinceEpoch hours: 0 minutes: 0 seconds: 0)) asSeconds.
-
- MilliSecondOffset := (secondsSinceMidnight * 1000 -
LastMilliSeconds)
- !
Item was changed:
----- Method: DateAndTime class>>milliSecondsSinceMidnight (in
category 'squeak protocol') -----
milliSecondsSinceMidnight
-
| msm msClock |
-
- msClock := self millisecondClockValue.
+ "This is usually only during system startup..."
+ self waitForOffsets.
- (
- msClock < LastMilliSeconds)
- ifTrue:[ "rolled over" MilliSecondOffset :=
MilliSecondOffset + (SmallInteger maxVal // 2) + 1 ].
+ msClock := self millisecondClockValue.
+ msClock < LastMilliSeconds ifTrue: [ "rolled over"
+ MilliSecondOffset := MilliSecondOffset + (SmallInteger
maxVal // 2) + 1 ].
LastMilliSeconds := msClock.
+ [
+ msm := msClock + MilliSecondOffset.
+ msm >= 86400000 ] whileTrue: [
+ "next day"
+ LastTick := -1.
+ DaysSinceEpoch := DaysSinceEpoch + 1.
+ MilliSecondOffset := MilliSecondOffset - 86400000 ].
-
- [ msm := msClock + MilliSecondOffset.
- (msm >= 86400000) ]
- whileTrue: [ "next day"
- LastTick := -1.
- DaysSinceEpoch := DaysSinceEpoch + 1.
- MilliSecondOffset := MilliSecondOffset - 86400000 ].
-
"day rolled over sanity check"
+ (LastTick = -1 and: [
+ (Duration
+ days: SqueakEpoch
+ hours: 0
+ minutes: 0
+ seconds: self clock totalSeconds) days ~=
DaysSinceEpoch ]) ifTrue: [
+ self initializeOffsets.
+ ^ self milliSecondsSinceMidnight ].
+ ^ msm.!
- ((LastTick = -1) and: [
- (Duration days: SqueakEpoch hours: 0 minutes: 0
seconds:
(self clock totalSeconds)) days ~= DaysSinceEpoch ])
- ifTrue:
- [ self initializeOffsets.
- ^ self milliSecondsSinceMidnight ].
-
- ^msm
-
-
-
- !
Item was changed:
----- Method: DateAndTime class>>now (in category 'ansi protocol') -----
now
| nanoTicks msm |
nanoTicks := (msm := self milliSecondsSinceMidnight) * 1000000.
(LastTick < nanoTicks) ifTrue: [
LastTick := nanoTicks.
^ self todayAtMilliSeconds: msm].
+ LastTickSemaphore critical: [
- LastTickSemaphore critical: [
LastTick := LastTick + 1.
^ self todayAtNanoSeconds: LastTick]
"
[ 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 changed:
----- Method: DateAndTime class>>startUp: (in
category 'initialize-release') -----
+ startUp: resuming
+ resuming ifFalse: [ ^ self ].
+ OffsetsAreValid := false.
+ [
+ self initializeOffsets.
+ OffsetsAreValid := true
+ ] forkAt: Processor userInterruptPriority.!
- startUp: resuming
-
- resuming ifFalse: [^ self].
-
- [ self initializeOffsets ] fork.
-
- !
Item was changed:
----- Method: DateAndTime class>>todayAtMilliSeconds: (in category 'squeak
protocol') -----
todayAtMilliSeconds: milliSecondsSinceMidnight
+ "This is usually only during system startup..."
+ self waitForOffsets.
+
^ self basicNew
setJdn: DaysSinceEpoch
seconds: (milliSecondsSinceMidnight // 1000)
nano: (milliSecondsSinceMidnight \\ 1000 * 1000000
)
offset: self localOffset
"
+ [ 100000 timesRepeat: [ self fromMilliSeconds: self
milliSecondsSinceMidnight. ] ] timeToRun.
- [ 100000 timesRepeat: [ self fromMilliSeconds: self
milliSecondsSinceMidnight. ] ] timeToRun.
"!
Item was changed:
----- Method: DateAndTime class>>todayAtNanoSeconds: (in category 'squeak
protocol') -----
todayAtNanoSeconds: nanoSecondsSinceMidnight
+ "This is usually only during system startup..."
+ self waitForOffsets.
+
^ self basicNew
setJdn: DaysSinceEpoch
seconds: (nanoSecondsSinceMidnight // 1000000000)
nano: (nanoSecondsSinceMidnight \\ 1000000000 )
offset: self localOffset
!
Item was added:
+ ----- Method: DateAndTime class>>waitForOffsets (in
category 'initialize-release') -----
+ waitForOffsets
+ OffsetsAreValid ifFalse: [
+ [
+ (Delay forSeconds: 1) wait.
+ OffsetsAreValid
+ ] whileFalse
+ ]!
Nov. 11, 2010
[Pharo-project] Issue 3236 in pharo: Cuis DateAndTime Enhancement
by pharo@googlecode.com
Status: Accepted
Owner: stephane.ducasse
Labels: Type-Squeak
New issue 3236 by stephane.ducasse: Cuis DateAndTime Enhancement
http://code.google.com/p/pharo/issues/detail?id=3236
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.512.mcz
==================== Summary ====================
Name: Kernel-ul.512
Author: ul
Time: 7 November 2010, 12:05:13.149 am
UUID: f35cd221-68a5-f04b-b6bc-d07df326b3d3
Ancestors: Kernel-nice.511
- DateAndTime startup enhancement from Cuis part 1
=============== Diff against Kernel-nice.511 ===============
Item was changed:
Magnitude subclass: #DateAndTime
instanceVariableNames: 'seconds offset jdn nanos'
+ classVariableNames: 'ClockProvider DaysSinceEpoch LastMilliSeconds
LastTick LastTickSemaphore LocalTimeZone MilliSecondOffset OffsetsAreValid'
- classVariableNames: 'ClockProvider DaysSinceEpoch LastMilliSeconds
LastTick LastTickSemaphore LocalTimeZone MilliSecondOffset'
poolDictionaries: 'ChronologyConstants'
category: 'Kernel-Chronology'!
!DateAndTime commentStamp: 'brp 5/13/2003 08:07' prior: 0!
I represent a point in UTC time as defined by ISO 8601. I have zero
duration.
My implementation uses three SmallIntegers
and a Duration:
jdn - julian day number.
seconds - number of seconds since midnight.
nanos - the number of nanoseconds since the second.
offset - duration from UTC.
The nanosecond attribute is almost always zero but it defined for full ISO
compliance and is suitable for timestamping.
!
Item was added:
+ (PackageInfo named: 'Kernel') postscript: 'DateAndTime classPool at:
#OffsetsAreValid put: true'!
Nov. 11, 2010
[Pharo-project] Issue 3235 in pharo: better bag sum
by pharo@googlecode.com
Status: FixedWaitingToBePharoed
Owner: stephane.ducasse
Labels: Type-Squeak Difficulty-Easy
New issue 3235 by stephane.ducasse: better bag sum
http://code.google.com/p/pharo/issues/detail?id=3235
- reimplemented Bag >> #sum to fix http://bugs.squeak.org/view.php?id=6560
=============== Diff against Collections-ul.402 ===============
Item was changed:
----- Method: Bag>>sum (in category 'math functions') -----
sum
"Faster than the superclass implementation when you hold many
instances of the same value (which you probably do, otherwise you wouldn't
be using a Bag)."
+
+ | sum first |
+ first := true.
+ contents keysAndValuesDo: [ :value :count |
+ first
+ ifTrue: [ sum := value * count. first := false ]
+ ifFalse: [ sum := sum + (value * count) ] ].
+ first ifTrue: [ self errorEmptyCollection ].
- | sum |
- sum := 0.
- contents keysAndValuesDo: [:value :count | sum := sum + (value *
count)].
^sum!
Nov. 11, 2010
[Pharo-project] Issue 3234 in pharo: fold: reduce: Merge
by pharo@googlecode.com
Status: FixedWaitingToBePharoed
Owner: stephane.ducasse
Labels: Type-Squeak
New issue 3234 by stephane.ducasse: fold: reduce: Merge
http://code.google.com/p/pharo/issues/detail?id=3234
I imagine that reduce: and fold: are not the same in pharo so we should pay
attention.
Name: Collections-ul.403
Author: ul
Time: 7 November 2010, 1:55:55.898 am
UUID: 7f81b384-8004-cd44-81e0-9b294d999c8a
Ancestors: Collections-ul.402
- merged Collection's #fold: and #reduce: (it's a bit faster than the
original versions :))
Item was changed:
----- Method: Collection>>fold: (in category 'enumerating') -----
fold: binaryBlock
"Evaluate the block with the first two elements of the receiver,
then with the result of the first evaluation and the next element,
and so on. Answer the result of the final evaluation. If the
receiver
is empty, raise an error. If the receiver has a single element,
answer
that element."
"#('if' 'it' 'is' 'to' 'be' 'it' 'is' 'up' 'to' 'me') fold: [:a :b |
a, ' ', b]"
+ ^self reduce: binaryBlock!
- | firstValue nextValue |
- firstValue := nextValue := Object new. "something that can't be in
the receiver"
- self do:
- [:each |
- nextValue := firstValue == nextValue
- ifTrue: [each]
- ifFalse: [binaryBlock
value: nextValue value: each]].
- ^nextValue == firstValue
- ifTrue: [self errorEmptyCollection]
- ifFalse: [nextValue]!
Item was changed:
----- Method: Collection>>reduce: (in category 'enumerating') -----
reduce: binaryBlock
"Apply the argument, binaryBlock cumulatively to the elements of the
receiver.
For sequenceable collections the elements will be used in order, for
unordered
collections the order is unspecified."
| first nextValue |
- self emptyCheck.
first := true.
+ self do: [ :each |
+ first
+ ifTrue: [ nextValue := each. first := false ]
+ ifFalse: [ nextValue := binaryBlock value:
nextValue value: each ] ].
+ first ifTrue: [ self errorEmptyCollection ].
- self do:[:each|
- first ifTrue:[nextValue := each. first := false]
- ifFalse:[nextValue := binaryBlock value: nextValue
value: each]].
^nextValue!
Nov. 11, 2010
[Pharo-project] Issue 3233 in pharo: Tests for WeakSet
by pharo@googlecode.com
Status: FixedWaitingToBePharoed
Owner: stephane.ducasse
Labels: Type-Squeak
New issue 3233 by stephane.ducasse: Tests for WeakSet
http://code.google.com/p/pharo/issues/detail?id=3233
Levente Uzonyi uploaded a new version of CollectionsTests to project The
Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.175.mcz
==================== Summary ====================
Name: CollectionsTests-ul.175
Author: ul
Time: 7 November 2010, 3:17:19.921 am
UUID: 4b82952d-1507-5249-ba8a-9f93a4aaa9f9
Ancestors: CollectionsTests-ul.174
- integrated tests for WeakSet from http://bugs.squeak.org/view.php?id=7350
=============== Diff against CollectionsTests-ul.174 ===============
Item was added:
+ ----- Method: WeakSetTest>>testAddIncludesSizeReclaim (in
category 'testing') -----
+ testAddIncludesSizeReclaim
+ | ws o2 o3 |
+ o2 := 1/2.
+ o3 := '123' copy.
+ ws := WeakSet new.
+ ws add: o2.
+ ws add: o3.
+ self assert: ws size = 2.
+ self assert: (ws includes: o2).
+ self assert: (ws includes: o3).
+
+ "inclusion test does use equality, not identity"
+ self assert: (ws includes: o3 copy) description: 'WeakSet are not
WeakIdentitySet'.
+
+ "only one copy is added"
+ ws add: o3 copy.
+ self assert: ws size = 2.
+
+ "reclame objects so that slots of ws are nilled out"
+ o2 := o3 := nil.
+ Smalltalk garbageCollect.
+ self deny: (ws includes: 1/2).
+ self deny: (ws includes: '123' copy).
+
+ "fast #size is not updated automatically by dead object reclamation
+ But there is a slowSize trying to tell the truth"
+ self assert: ws slowSize = 0.!
Item was added:
+ ----- Method: WeakSetTest>>testCollisions (in category 'testing') -----
+ testCollisions
+
+ | ws o1 o2 o5 on remember forget |
+
+ "create a weak set"
+ ws := WeakSet new: 15.
+
+ "select some fractions wanting same place in ws array"
+ o1 := (2 to: 100) select: [:i | (ws scanFor: 1 / i) == 1].
+ o2 := (2 to: 100) select: [:i | (ws scanFor: 1 / i) == 2].
+ o5 := (2 to: 100) select: [:i | (ws scanFor: 1 / i) == 5].
+ on := (2 to: 100) select: [:i | (ws scanFor: 1 / i) == (ws array
size - 1)].
+
+ "Add some fractions to the weak set, and remember a pointer for a
few of them"
+ remember := OrderedCollection new.
+ forget := OrderedCollection new.
+ ws add: (remember add: 1 / o1 first).
+ ws add: (forget add: 1 / on second).
+ ws add: (forget add: 1 / o1 second).
+ ws add: (forget add: 1 / o5 second).
+ ws add: (forget add: 1 / o2 second).
+ ws add: (forget add: 1 / o1 third).
+ ws add: (remember add: 1 / o2 first).
+ ws add: (forget add: 1 / o5 third).
+ ws add: (forget add: 1 / on third).
+ ws add: (remember add: 1 / o2 fourth).
+ ws add: (remember add: 1 / on first).
+ ws add: (remember add: 1 / o5 first).
+
+ "forget and reclaim all entries but those in remember"
+ forget := nil.
+ Smalltalk garbageCollect.
+
+ remember do: [:m | self assert: (ws includes: m)].
+ ws add: 1/on second.
+ remember do: [:m | self assert: (ws includes: m)].
+
+ ws add: (remember add: 1 / o1 fourth).
+ ws add: (remember add: 1 / on fourth).
+ remember remove: (ws remove: (1 / o5 first)).
+ remember remove: (ws remove: (1 / on first)).
+ remember remove: (ws remove: (1 / o2 first)).
+ remember remove: (ws remove: (1 / o1 first)).
+ remember do: [:m | self assert: (ws includes: m)].
+ ws add: 1/on second.
+ ws add: 1/o5 second.
+ remember do: [:m | self assert: (ws includes: m)].
+ !
Item was added:
+ ----- Method: WeakSetTest>>testDoDontIterateOnReclaimedObjects (in
category 'testing') -----
+ testDoDontIterateOnReclaimedObjects
+
+ | ws o1 o2 size |
+ ws := WeakSet new.
+ 2 to: 20 do: [:i | ws add: 1 / i].
+
+ o1 := 3.0.
+ o2 := 4.0.
+ ws add: o1; add: o2.
+
+ "Reclaim memory"
+ Smalltalk garbageCollect.
+
+ size := 0.
+ ws do: [:each |
+ size := size + 1.
+ self deny: each isNil].
+
+ self assert: size = 2!
Item was added:
+ ----- Method: WeakSetTest>>testGrowWhenNecessary (in category 'testing')
-----
+ testGrowWhenNecessary
+ | ws objs initialSize |
+ objs := (2 to: 20) collect: [:i | 1 / i].
+ ws := WeakSet new: 5.
+ initialSize := ws array size.
+ 1 to: objs size do: [:k | ws add: (objs at: k)].
+ self assert: ws array size > initialSize
+ description: 'The WeakSet grown because not enough room
were preallocated'.!
Item was added:
+ ----- Method: WeakSetTest>>testIncludesNil (in category 'testing') -----
+ testIncludesNil
+
+ | ws |
+ ws := WeakSet new.
+ self deny: (ws includes: nil).
+
+ "After reclamation, should not includes nil: nil counts for nothing"
+ ws add: 1/2.
+ ws add: 1/3.
+ Smalltalk garbageCollect.
+ self deny: (ws includes: nil).!
Nov. 11, 2010
[Pharo-project] Issue 3232 in pharo: SharedQueue code simplication
by pharo@googlecode.com
Status: FixedWaitingToBePharoed
Owner: stephane.ducasse
Labels: Type-Squeak
New issue 3232 by stephane.ducasse: SharedQueue code simplication
http://code.google.com/p/pharo/issues/detail?id=3232
We should really review carefully this changes
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ul.404.mcz
==================== Summary ====================
Name: Collections-ul.404
Author: ul
Time: 7 November 2010, 4:52:11.401 am
UUID: 2e0defd1-6e46-7243-be6f-b571c6805ae4
Ancestors: Collections-ul.403
- simplified SharedQueue >> #makeRoomAtEnd
- enhanced SharedQueue >> #peek
=============== Diff against Collections-ul.403 ===============
Item was changed:
----- Method: SharedQueue>>makeRoomAtEnd (in category 'private') -----
makeRoomAtEnd
+ | contentsSize newContentsArray |
- | contentsSize |
contentsSize := writePosition - readPosition.
+ newContentsArray := contentsSize * 2 > contentsArray size
+ ifTrue: [ contentsArray class new: contentsArray size * 2 ]
- contentsSize * 2 > contentsArray size
- ifTrue: [
- "grow"
- contentsArray := (contentsArray class new:
contentsArray size * 2)
- replaceFrom: 1
- to: contentsSize
- with: contentsArray
- startingAt: readPosition;
- yourself ]
ifFalse: [
(contentsArray size > 10 and: [ contentsSize * 4 <=
contentsArray size ])
+ ifTrue: [ contentsArray class new:
(contentsSize * 2 max: 10) ]
+ ifFalse: [ contentsArray ] ].
+ newContentsArray
+ replaceFrom: 1
+ to: contentsSize
+ with: contentsArray
+ startingAt: readPosition.
+ contentsArray == newContentsArray
+ ifFalse: [ contentsArray := newContentsArray ]
+ ifTrue: [ contentsArray from: contentsSize + 1 to:
contentsArray size put: nil ].
- ifTrue: [
- "shrink"
- contentsArray := (contentsArray
class new: (contentsSize * 2 max: 10))
- replaceFrom: 1
- to: contentsSize
- with: contentsArray
- startingAt: readPosition;
- yourself ]
- ifFalse: [
- "just move the elements to the
front"
- contentsArray
- replaceFrom: 1
- to: contentsSize
- with: contentsArray
- startingAt: readPosition.
- contentsArray
- from: contentsSize + 1
- to: contentsArray size
- put: nil ] ].
readPosition := 1.
writePosition := contentsSize + 1!
Item was changed:
----- Method: SharedQueue>>peek (in category 'accessing') -----
peek
"Answer the object that was sent through the receiver first and has
not
yet been received by anyone but do not remove it from the receiver.
If
no object has been sent, return nil"
+ readSynch isSignaled ifFalse: [ ^nil ].
+ ^accessProtect critical: [
+ readPosition >= writePosition ifFalse: [
+ contentsArray at: readPosition ] ]!
- ^accessProtect
- critical: [
- | value |
- readPosition >= writePosition
- ifTrue: [readPosition := 1.
- writePosition := 1.
- value := nil]
- ifFalse: [value := contentsArray
at: readPosition].
- value].!
Nov. 11, 2010
[Pharo-project] Issue 3231 in pharo: Semaphore changes
by pharo@googlecode.com
Status: FixedWaitingToBePharoed
Owner: stephane.ducasse
CC: siguctua
Labels: Type-Squeak
New issue 3231 by stephane.ducasse: Semaphore changes
http://code.google.com/p/pharo/issues/detail?id=3231
Needs a really careful review....
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ul.514.mcz
==================== Summary ====================
Name: Kernel-ul.514
Author: ul
Time: 7 November 2010, 4:21:51.529 pm
UUID: 5710b62a-4264-9947-acdc-11e0ce45021d
Ancestors: Kernel-ul.513
A few changes to Semaphore:
- save a block creation + activation + a possible context switch in
#critical:ifCurtailed:
- save a block creation + activation in #critical:ifError:, this changes
the behavior when mutuallyExcludedBlock doesn't understand #ifError:
- #critical:ifLocked: is guaranteed to not get locked. The earlier
implementation sent #critical: which could cause a context change, so
another process could enter the critical section before the original.
- added a new method #passIfLocked: which is like #wait, but it doesn't
wait for a signal if there's none, but evaluates the argument instead.
=============== Diff against Kernel-ul.513 ===============
Item was changed:
----- Method: Semaphore>>critical:ifCurtailed: (in category 'mutual
exclusion') -----
critical: mutuallyExcludedBlock ifCurtailed: terminationBlock
"Evaluate mutuallyExcludedBlock only if the receiver is not
currently in
the process of running the critical: message. If the receiver is,
evaluate
mutuallyExcludedBlock after the other critical: message is finished."
+ ^self critical: [ mutuallyExcludedBlock ifCurtailed:
terminationBlock ]
- ^self critical:[[mutuallyExcludedBlock value] ifCurtailed:
terminationBlock]
!
Item was changed:
----- Method: Semaphore>>critical:ifError: (in category 'mutual
exclusion') -----
critical: mutuallyExcludedBlock ifError: errorBlock
"Evaluate mutuallyExcludedBlock only if the receiver is not
currently in
the process of running the critical: message. If the receiver is,
evaluate
mutuallyExcludedBlock after the other critical: message is finished."
| blockValue hasError errMsg errRcvr |
hasError := false.
blockValue := self critical:[
+ mutuallyExcludedBlock ifError: [ :msg :rcvr |
- [mutuallyExcludedBlock value] ifError:[:msg :rcvr|
hasError := true.
errMsg := msg.
errRcvr := rcvr
].
].
hasError ifTrue:[ ^errorBlock value: errMsg value: errRcvr].
^blockValue!
Item was changed:
----- Method: Semaphore>>critical:ifLocked: (in category 'mutual
exclusion') -----
critical: mutuallyExcludedBlock ifLocked: alternativeBlock
"Evaluate mutuallyExcludedBlock only if the receiver is not
currently in
the process of running the critical: message. If the receiver is,
evaluate
mutuallyExcludedBlock after the other critical: message is finished."
-
"Note: The following is tricky and depends on the fact that the VM
will not switch between processes while executing byte codes (process
switches happen only in real sends). The following test is written
carefully so that it will result in bytecodes only."
+
+ | caught |
+ caught := false.
+ ^[
+ excessSignals = 0
+ ifTrue: [ alternativeBlock value ]
+ ifFalse: [
+ excessSignals := excessSignals - 1.
+ caught := true.
+ mutuallyExcludedBlock value ] ]
+ ensure: [ caught ifTrue: [ self signal ] ]!
- excessSignals == 0 ifTrue:[
- "If we come here, then the semaphore was locked when the
test executed.
- Evaluate the alternative block and answer its result."
- ^alternativeBlock value
- ].
- ^self critical: mutuallyExcludedBlock!
Item was added:
+ ----- Method: Semaphore>>passIfLocked: (in category 'communication') -----
+ passIfLocked: aBlock
+
+ excessSignals = 0 ifTrue: [ ^aBlock value ].
+ excessSignals := excessSignals - 1!
Nov. 11, 2010