[Pharo-project] start-up and shut-down lists

Eliot Miranda eliot.miranda at gmail.com
Fri Jul 13 15:09:16 EDT 2012


Hi All,

    I'm profiling image startup and consequently want to pause a
MessageTally during a snapshot.  So I want to add MessageTally to the
StartUpList immediately after Delay (the first entry in StartUpList) and to
the ShutDownList immediately before Delay.  But when I look at the
SmalltalkImage accessor I see some confusion:

SmalltalkImage>add: aClass toList: startUpOrShutDownList after: predecessor
"Add the name of aClass to the startUp or shutDown list.
Add it after the name of predecessor, or at the end if predecessor is nil."

| name earlierName |
name := aClass name.
(self at: name ifAbsent: [nil]) == aClass ifFalse:
[self error: name , ' cannot be found in Smalltalk dictionary.'].
predecessor == nil
ifTrue: ["No-op if alredy in the list."
(startUpOrShutDownList includes: name) ifFalse:
[startUpOrShutDownList == StartUpList
ifTrue: ["Add to end of startUp list"
startUpOrShutDownList addLast: name]
ifFalse: ["Add to front of shutDown list"
startUpOrShutDownList addFirst: name]]]
ifFalse: ["Add after predecessor, moving it if already there."
earlierName := predecessor name.
(self at: earlierName) == predecessor ifFalse:
[self error: earlierName , ' cannot be found in Smalltalk dictionary.'].
(startUpOrShutDownList includes: earlierName) ifFalse:
[self error: earlierName , ' cannot be found in the list.'].
startUpOrShutDownList remove: name ifAbsent:[].
startUpOrShutDownList add: name after: earlierName]

In the predecessor == nil arm adding to the StartUpList adds at the end and
adding to the ShutDownList adds at the beginning, which makes sense, at
least to me.  But if predecessor is not nil then adding to either adds
after.  The asymmetry is troubling.  I guess in the name of stability the
only way to solve this is to add an explicit add:toList:before: and sugar
(add:toStartUpListBefore: add:toShutDownListBefore:).  So what's the
rationale for the asymmetry, or is it an unintentional mistake?
-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20120713/f2745465/attachment-0001.html>


More information about the Pharo-dev mailing list