Multi-thread Question in Morph?
Boris Gaertner
Boris.Gaertner at gmx.net
Sat Jan 31 21:36:11 UTC 2004
From: ducasse <ducasse at iam.unibe.ch> wrote:
<snip>
> Now I have the following problem that you can try just by loading the
> cs.
> If I create a morph NewBot new openInWorld, inspect it and execute self
> diamNumber in an inspector, the complete environment
> is blocked.
>
> I simplified the problem to its essence in the attached file. If you
> open an inspect and evaluate self diamNumber
> the system freezes. Apparently there is not enough thread in morphic.
> So I started to see where I could
> put another thread. The problem is that
> - in an inspector doing [self diamNumber] fork does not help because I
> would need another future to get the value form the thread
> - opening an inspector in another block (self inspect fork) and in this
> new inspector doing self diamNumber still freezes the system
> My impression is that the UI scheduler does not let me doing that.
>
>
I am not convinced that this is the fault of the UI scheduler.
You can try this:
1. In NewBot, add this instance method:
diamNumberPromise
^ (self addAction: #diamNumberPrimitive)
2. Open a Transcript.
3. Evaluate [NewBot new inspect]. An inspector appears.
4. in the evaluation pane of the inspector evaluate
this:
| p s |
s := Semaphore new.
[ p := self diamNumberPromise.
s signal. " p has now a value "
Transcript show: p result printString; cr] fork.
s wait. " wait until p has a value "
p inspect
In the Transcript you see that your future is waiting.
You get a second inspector, this time for an instance of
BotCommand.
5. In the evaluation pane of the inspector for the
BotCommand, evaluate:
self setFutureValue: 7
In the transcript, you see the second part of the story: Reception
of the value.
I think the problem is simply that, as soon as processes come into
play, one has to construct expressions for inspection very carefully.
Greetings, Boris
More information about the Squeak-dev
mailing list
|