AbstractSourceFileReader.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 25 Mar 2021 20:30:03 +0000
branchjv
changeset 25411 248600ba8fd9
parent 18919 dbe023989a90
permissions -rw-r--r--
Fix unlikely but possible race in `WeakValueDictionary` It may happen that value in `valueArray` could have been already collected by the GC but #clearDeadSlots have not yet been called. When this happened, `#at:ifAbsentPut:` returned tombstone rather than updating the dictionary with value from block. This commit fixes this by checking whether `valueArray` contain the tombstone and if so, clearing up the dead slots and restarting the operation. HTH.

"{ Package: 'stx:libbasic' }"

"{ NameSpace: Smalltalk }"

Object subclass:#AbstractSourceFileReader
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Classes-Support'
!

!AbstractSourceFileReader class methodsFor:'documentation'!

documentation
"
    Abstract common superclass for source file readers
"
! !

!AbstractSourceFileReader class methodsFor:'fileIn'!

fileIn: aFilename

    ^self new fileIn: aFilename

    "Created: / 16-08-2009 / 10:14:51 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

fileInStream: aStream

    ^self new fileInStream: aStream

    "Created: / 16-08-2009 / 10:15:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!AbstractSourceFileReader class methodsFor:'queries'!

isAbstract
    ^ self == AbstractSourceFileReader
! !

!AbstractSourceFileReader methodsFor:'fileIn'!

fileIn:aFilename

    | stream |
    [stream := aFilename asFilename readStream.
    self fileInStream: stream]
        ensure:
            [stream notNil ifTrue:[stream close]]

    "Modified: / 15-08-2009 / 14:47:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 08-08-2010 / 14:38:35 / cg"
!

fileInStream:arg
    "raise an error: must be redefined in concrete subclass(es)"

    ^ self subclassResponsibility
! !

!AbstractSourceFileReader class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
!

version_SVN
    ^'$Id$'
! !