Is Set growth thread-safe?

Bert Freudenberg bert at impara.de
Thu Sep 22 23:36:04 UTC 2005


Am 22.09.2005 um 20:43 schrieb Ross Boylan:
>
> By the usual logic of
> providing thread-safety around classes as needed, wouldn't it be
> better for Object, Model, and EventModel to protect the update
> mechanisms appropriately?

No, because those mechanisms are intended to be used from the main UI  
thread. You should not send "changed" messages from a non-UI process,  
because they are handled synchronously (sending "update" messages  
etc). You need to asynchronously let the UI process know it should act.

There are several ways to accomplish this. A commonly used one in  
Morphic is this:

     WorldState addDeferredUIMessage: [...]

You can call this from a background process, the block will later be  
executed in the UI process. Internally, it uses a SharedQueue holding  
the blocks.

- Bert -




More information about the Squeak-dev mailing list