OmniBase BTreeDictionary>>valueAt:ifAbsent:
Derek Brans
brans at nerdonawire.com
Tue Jul 8 00:08:37 UTC 2003
The ifAbsentBlock is being evaluated in the critical section of this method. As a result, this block cannot modify the btreeDictionary. If we move the ifAbsentBlock evaluation to outside of the critical section would this method still be "correct"? Here is how it would read:
valueAt: aKey ifAbsent: aBlock
"Private - Answer correct version of value holder at aKey,
evaluate aBlock if absent."
| value |
changed == nil ifFalse: [
value := changed at: aKey.
value == nil ifFalse: [ ^value ]
].
dataBaseObject == nil ifTrue: [ ^aBlock value ].
"critical section begin"
mutex critical: [
(value := dataBaseObject iterator goTo: aKey; getCurrent) ].
"critical section end"
"evaluate aBlock outside the critical section"
value == nil
ifTrue: [^aBlock value].
value := ODBValueHolder createOn: value value.
[transaction versionDescriptor versionOK: value versionNumber]
whileFalse: [value loadPreviousVersionFrom: transaction oldHolders].
^value
Thanks.
Derek Brans
Nerd on a Wire
Web design that's anything but square
http://www.nerdonawire.com
mailto: brans at nerdonawire.com
phone: 604.874.6463
toll-free: 1-877-NERD-ON-A-WIRE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030707/4aa3f669/attachment.htm
More information about the Squeak-dev
mailing list
|