Publish-Subscribe
Stephen Pair
spair at advantive.com
Mon Jun 7 23:35:40 UTC 1999
This sounds suspiciously like something else I encountered when writing the
External Memory stuff. The problem I found was that there are numerous
places in the collection hierarchy where explicit returns are found inside a
#do: block. The example I encountered was:
Collection>>includes: anObject
"Answer whether anObject is one of the receiver's elements."
self do: [:each | anObject = each ifTrue: [^true]].
^false
....and where it caused problems for me was when you send #includes: to an
instance of a WeakRegistry. Since #do: in WeakRegistry is implemented as
follows:
do: aBlock
^self protected:[
valueDictionary keysDo: aBlock.
].
....the block will return from the #includes: context before the mutex
Semaphore has been signaled...hence subsequent uses of the WeakRegistry will
result in an indefinte wait on a Semaphore that will never be signaled.
The solution here seems to be an appropriate use of #ensure: blocks. I
think that has been added by Craig Latta's exception handling framework.
As a temporary fix for my situation, I overrided #includes: in WeakRegistry
as follows:
includes: anObject
"Answer whether anObject is one of the receiver's elements.
Overridden here because the super implementation has an explicit
return inside the do block...Squeak needs an implementation of #ensure:
to handle this correctly. Note: it's likely this issues will crop up
elsewhere."
self do: [:each |
anObject = each ifTrue: [
accessLock isNil ifFalse: [ accessLock signal ].
^true
]
].
^false
....which is ugly.
Hope that helps...in case it doesn't it might be useful for others.
- Stephen
> -----Original Message-----
> From: Peter Smet [mailto:peter.smet at flinders.edu.au]
> Sent: Monday, June 07, 1999 6:36 PM
> To: shaping at bigfoot.com
> Cc: squeak at cs.uiuc.edu
> Subject: Re: Publish-Subscribe
>
>
>
> I have sent you the original 2 versions of Publish Subscribe.
> The WeakKeyDictionaries (publishers) have always been weak dependents of
> WeakArray,
> so that is not likely to be the source of the problems you have
> been having.
> Finalization was handled this way right from version 0.
> I think the problems are more likely to involve some sort of deadlock or
> other synchronization problem. If you don't need process-safe code, the
> quickest fix is simply to remove the #protected: block from the 3 or 4
> methods
> in PostOffice that use it. Then test using the class side tests
> individually,
> but don't run the 'start' process - that test is virtually guaranteed to
> cause
> problems.
>
>
> I am going to look at the synchronization stuff in detail soon, but have
> some
> exams looming that I must take care of first.
>
> Let me know if this fixes things.
>
>
> >Peter:
> >
> >I'm working on my event system, again, and need at least a
> partial fix for
> >you stuff. Unfortunately, I tossed the older, working versions. The
> >problem seems to have started when you made the publishers dictionary a
> weak
> >dependent of WeakArray (if I recall correctly). I don't remember how you
> >handled finalization before that. I don't need Smalltalk-process-safe
> code,
> >now, just something to get me by.
> >
> >(I don't know whether you received my previous e-mail: the latest
> >Publish-Subscribe change when tested will hang a clean 2.4c /w updates.)
> >
> >Thanks.
> >
> >Shaping
> >
> >
>
>
More information about the Squeak-dev
mailing list
|