[squeak-dev] Re: Example of non-concurrent code :)

Igor Stasenko siguctua at gmail.com
Sat Oct 16 05:16:55 UTC 2010


On 16 October 2010 08:00, Andreas Raab <andreas.raab at gmx.de> wrote:
> On 10/15/2010 9:41 PM, Igor Stasenko wrote:
>>
>> Here, the bug:
>> first it sends #peekEvent and its not nil.
>> Okay, then after some logic voodo, it sends nextEvent, without
>> precaution, that it may also answer nil!
>>
>> So, if some other process get between these two sends (*a*, *b*) and
>> fetch/flush all events, a code will fail,
>
> But there is no such code. The method in question is run from within Morphic
> so unless there is a concurrent thread which for some reason flushes the
> event queue[*1], this case simply cannot happen. The shared queue used for
> synchronization here is specifically for synchronizing the event queue with
> the Morphic event loop. It's not for general purpose
> let's-just-dump-all-events-at-random-points-in-time usage.
>
> [*1] I would claim that such code itself buggy. Flushing the event queue
> should be synchronized with Morphic.
>

There are 209 references to Sensor in my image.
How i can be sure that every place does not using it outside a Morphic
UI process?

> Cheers,
>  - Andreas
>
>> The fix is simple:
>>
>> nextEvent := Sensor nextEvent.
>> nextEvent ifNotNil: [ trail nextPut: nextEvent third @ nextEvent fourth]
>>
>> Both Pharo&  Squeak contain this bug. But this method slightly differs
>> from each other.
>>
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list