[Cuis-dev] Strange behavior with stepping
Juan Vuletich
juan at jvuletich.org
Sat Aug 21 10:44:34 PDT 2021
Hi Folks,
On 8/21/2021 2:22 PM, Phil B via Cuis-dev wrote:
> Gerald,
>
> On Sat, Aug 21, 2021 at 9:04 AM Gerald Klix via Cuis-dev
> <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> wrote:
>
> Hi Hilaire,
>
> I only did a short static analysis
> (a fancy word for looking at the code
> and scratching your head).
>
> IHMO there's a race condition:
>
> WorldMorph>>#runLocalStepMethods
>
> | stepMessage |
> [ stepList notEmpty and:
> [ stepList first scheduledTime <= nowTime ]]
> whileTrue: [
> stepMessage _ stepList first.
>
>
> This piece of code looks at the scheduleTime of the
> heap's first element then actually retrieves
> the first element.
> While this happens the heap in stepList may
> be changed by adding or removing elements.
>
>
> If that is the issue, I think there's a larger problem to be solved.
> Morphic is inherently not thread safe so you're dealing with an
> intractable problem (short of re-architecting Morphic.) Other than
> marking a morph for redraw, anything else touching Morphic from a
> background process needs to be wrapped in UISupervisor
> whenUIinSafeState: [].
This is of course true!!!
Hilaire, if you are sending any message that alters Morphic state from a
different process, follow Phil's advice. It might make things more
complicated, as possibly your process would need to wait until that
block is effectively run, possibly using a Semaphore.
>
> Please try the attached method and tell me if it helps.
>
> @Juan: Even if my change does not fix Hilaire's problem
> the method should still be changed.
>
>
> HTH,
>
> Gerald
>
>
> Thanks,
> Phil
Thanks,
--
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210821/7b9489bd/attachment.htm>
More information about the Cuis-dev
mailing list