Publish-Subscribe - much improved...

Peter Smet peter.smet at flinders.edu.au
Sat Jun 12 14:52:22 UTC 1999


After the comment by Stephen about failing to signal semaphores
by blocks with explicit ^ returns, I went through and checked my
Publish-Subscribe stuff with a fine-tooth comb. There were about
3 places where the flow of control allowed blocks to 'escape' without
signalling the semaphore. I suspect these were responsible for
the deadlock situations that some people described.

I think anyone who was having problems with the event framework
will find the attached version a huge improvement (Otherwise, it's
back to the drawing board for me....).

Just a reminder of what Publish-Subscribe does - it allows contructs
of the form:
publisherObject when: #eventSymbol send: #selector to: subscriberObject.
publisherObject trigger: #eventSymbol.

All references to publishers and subscribers are held in
weakKeyDictionaries,
and are automatically garbage collected.

Thanks all for your collective help!

Peter


>
>>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.


Content-Type: application/octet-stream;
	name="Publish-Subscribe-cut.12Jun1158pm.cs"
Content-Disposition: attachment;
	filename="Publish-Subscribe-cut.12Jun1158pm.cs"

Attachment converted: Anon:Publish-Subscribe-cut.12Jun1158 
(????/----) (0000AB71) 





More information about the Squeak-dev mailing list