[squeak-dev] Changeset: Eliminating global state from Morphic

Marcel Taeumel marcel.taeumel at hpi.de
Mon Sep 28 09:01:05 UTC 2020


Hi Christoph.

>> It's true that in Morphic there is one distinct Process associated
>> with the user interface for each Morphic world.
> I'm not so sure about this. You can always do forks within UI code, 
> so sometimes there are also multiple Processes within one Morphic 
> world. Just think about Shout's background process or debugging
> processes, and please keep in mind that Jakob justifiably proposed to
> renew the process handling for non-modal dialogs, which maybe could
> also result in multiple processes being active at the same time.


There is (and should) only be a single UI process running in Morphic at any time. All other processes that can be scheduled must synchronize with that single UI process when doing UI stuff. Shout, for example, does that via #addDeferredUIMessage:, which is effectively a SharedQueue (using a Mutex or similar). Having two UI processes running (or be scheduled) at the same time will produce strange side effects or even lock up the image. I don't know. At least, things will slow down.

You could change that by re-desiging the ownership partitioning of UI objects. Even then, there will be some process responsible for a set of UI objects. All other processes must synchronize into that one when talking to those (foreign) UI objects.

I forgot. When does process switching happen through higher-priority processes having a semaphore ready (i.e. Delay >> #wait)? At byte-code level? Oder message-send level? Well, you might not see the effects of omitting such process synchronization immediately. However, occasionally, debuggers with "nil does not understand" may pop up. Causing you headaches. :-)

Best,
Marcel
Am 24.09.2020 14:08:56 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
Hi all,

sorry for the long delay on this issue. I'm attaching a new version of the changeset including the following changes:

* Use DynamicVariables for storing the active variable states
* Refactor and reduce the visibility of active variable accessors on Object
* Clean up implementations of #activeHand and #primaryHand

@Dave I think associating these objects to Process is an implementation detail of DynamicVariables which I would not like to denigrate in general.

[http://www.hpi.de/]

> It's true that in Morphic there is one distinct Process associated with the user interface for each Morphic world.

I'm not so sure about this. You can always do forks within UI code, so sometimes there are also multiple Processes within one Morphic world. Just think about Shout's background process or debugging processes, and please keep in mind that Jakob justifiably proposed to renew the process handling for non-modal dialogs, which maybe could also result in multiple processes being active at the same time.
A world can have multiple hands, for example, RemoteHandMorphs (Nebraska), event-simulating hands (EventRecorder), or just multiple plain HandMorphs as demonstrated by Tony recently in his PostmarketOS implementation. There is no reason for these hands to run on the same process. Analogously, I don't see why we should restrict a hand not to be thread-safe, so the hand-event relation is 1:n again.

PS: Thanks for the hint to the new wiki page!

Best,
Christoph

Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von David T. Lewis <lewis at mail.msen.com>
Gesendet: Montag, 14. September 2020 17:49:34
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] Changeset: Eliminating global state from Morphic
 
On Mon, Sep 14, 2020 at 11:17:53AM +0000, Thiede, Christoph wrote:
> Hi Dave,
>
>
> I agree that could try to place the active variables at better places than the most generic Object class. Still, I am not sure whether you are arguing against the thread-local storage of their values - which I do find pretty important for enabling concurrency.
>
>
> Of course, we could move my proposed implementation #activeWorld down to Project, and on Object, forward the request to "Project current activeWorld". Still, I do not think that an instance variable would be the right way to store the world, because it is not thread-local. If you would like to do this, we should implement some kind of PluggableThreadLocalVariable as proposed below, and store an instance of this class in Project.
>
>
> What do you think?
>

Hi Christoph,

The thing that I like (a lot) about your changes is that they make it
much easier to see and understand the accesses to the global variables.
The references now all go through a small number of methods in Object,
so that you can see what they do now.

Clearly we would want to leave this logic in Object, since we don't
want to add more clutter to its protocol. But you have collected the logic
in one place now, which makes it easier to think about where it ultimately
should go, and that's great.

But where do these things actually belong?  Thinking in terms of the
responsiblities of objects in the system [1], I don't think that associating
them with a Process seems to be a good fit. It's true that in Morphic there
is one distinct Process associated with the user interface for each Morphic
world. So you can make things work by associating these variables with
a Process, but it seems like an unnatural fit to me. A Morphic world has
a process, but a Process is not responsible for knowing the state of
the Morphic world.

Dave

[1] https://en.wikipedia.org/wiki/Responsibility-driven_design#:~:text=Responsibility%2Ddriven%20design%20is%20a,information%20that%20the%20object%20shares [https://en.wikipedia.org/wiki/Responsibility-driven_design#:~:text=Responsibility%2Ddriven%20design%20is%20a,information%20that%20the%20object%20shares].


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200928/0cec2cc6/attachment.html>


More information about the Squeak-dev mailing list