Re: Issue 114 in metacello: tight #currentVersion loop
Posted by
metacello on
Feb 25, 2011; 1:18am
URL: https://forum.world.st/Issue-114-in-metacello-tight-currentVersion-loop-tp3323714p3323730.html
Comment #1 on issue 114 by
[hidden email]: tight #currentVersion loop
http://code.google.com/p/metacello/issues/detail?id=114It looks like MetacelloPlatform>>stackCacheFor:at:doing: can catch the loop
with the following implementation:
stackCacheFor: cacheName at: key doing: aBlock
self
useStackCacheDuring: [:dict | | cache hasEntry |
hasEntry := true.
cache := dict at: cacheName ifAbsent: [].
cache ~~ nil
ifTrue: [ | value |
value := cache
at: key
ifAbsent: [
cache at: key put: #inProgress.
hasEntry := false ].
hasEntry
ifTrue: [
value == #inProgress ifTrue: [ self error: 'LOOP' ].
^value ]]
ifFalse: [
cache := Dictionary new.
dict at: cacheName put: cache.
cache at: key put: #inProgress.
hasEntry := false ].
^[ aBlock value: cache ] ensure: [
(hasEntry not and: [ (cache at: key) == #inProgress ])
ifTrue: [ cache removeKey: key ]]]
defaultDictionary: nil
Need to build some test cases to verify...