Jeff Gonis | 2 Jun 2010 00:11
Picon

Using Futures in a thread other than the Morphic Thread

Hi everyone,

I am currently experimenting with using futures in squeak as a very convenient method for creating processes to do background work in, but a problem I am running into is that they run in the Morphic thread it appears.  This means that if I have a particularly long lived chunk of work I can end up blocking the UI thread and having an unresponsive GUI.  Ideally what I would like to do is create a future, dispatch it onto a process running at userBackgroundPriority, and then block the UI only when I try to get the value from the Promise that is returned.

I know that I can use a block closure and the forkAt: method to get a process running at the userBackgroundPriority, but this doesn't give me the nice behaviour of a Promise where I can block until completion when I actually need the value my process will generate.

So my question is, am I missing something obvious here, or is dispatching futures to a different thread something that is being worked on for a "future" squeak release?

Thanks for your help,
Jeff G

_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Bert Freudenberg | 2 Jun 2010 01:42
Picon
Gravatar

Re: Using Futures in a thread other than the Morphic Thread

On 02.06.2010, at 00:11, Jeff Gonis wrote:

> Hi everyone,
> 
> I am currently experimenting with using futures in squeak as a very convenient method for creating
processes to do background work in, but a problem I am running into is that they run in the Morphic thread it
appears.  This means that if I have a particularly long lived chunk of work I can end up blocking the UI thread
and having an unresponsive GUI.  Ideally what I would like to do is create a future, dispatch it onto a
process running at userBackgroundPriority, and then block the UI only when I try to get the value from the
Promise that is returned.
> 
> I know that I can use a block closure and the forkAt: method to get a process running at the
userBackgroundPriority, but this doesn't give me the nice behaviour of a Promise where I can block until
completion when I actually need the value my process will generate.
> 
> So my question is, am I missing something obvious here, or is dispatching futures to a different thread
something that is being worked on for a "future" squeak release?
> 
> Thanks for your help,
> Jeff G

Future messages by definition are executed in the main thread, just at a later time. But you don't need
futures to create Promises, you can resolve them directly in your background process.

pr := Promise new.
[pr resolveWith: (... some lengthy computation ...)] forkAt: Processor userBackgroundPriority.
... do something else in foreground ...
result := pr wait.

- Bert -
Jeff G | 2 Jun 2010 02:23
Picon

Re: Using Futures in a thread other than the Morphic Thread

Thanks a ton Bert, that clears things up quite a bit.  I guess I was getting too wrapped up in considering Futures and Promises as being bound together rather than concepts I could use separately.

_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Yoshiki Ohshima | 2 Jun 2010 19:55
Gravatar

Re: How do I diff two images?

At Fri, 28 May 2010 10:55:31 -0600,
Clinton Blackmore wrote:
> 
> Very interesting.  It looks like I will probably not get to try any of these methods until next week, but,
what sort of
> adjustments do you think it would need for Scratch images?

  The biggest single issue is that my ImageBrowser depends on
InterpreterSimulator to load the image file and find out the object
pointers in it.  An older version of InterpreterSimulator that is
suitable for the Scratch image can be found somewhere (like in the
Squeak2.4 image) but bringing in it will take some efforts.

-- Yoshiki
Clinton Blackmore | 2 Jun 2010 20:03
Picon

Re: How do I diff two images?

Would it be easier to bring Scratch forward to run on a newer version of Squeak?


Clinton

On Wed, Jun 2, 2010 at 11:55 AM, Yoshiki Ohshima <yoshiki <at> vpri.org> wrote:
At Fri, 28 May 2010 10:55:31 -0600,
Clinton Blackmore wrote:
>
> Very interesting.  It looks like I will probably not get to try any of these methods until next week, but, what sort of
> adjustments do you think it would need for Scratch images?

 The biggest single issue is that my ImageBrowser depends on
InterpreterSimulator to load the image file and find out the object
pointers in it.  An older version of InterpreterSimulator that is
suitable for the Scratch image can be found somewhere (like in the
Squeak2.4 image) but bringing in it will take some efforts.

-- Yoshiki
_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Yoshiki Ohshima | 2 Jun 2010 20:16
Gravatar

Re: How do I diff two images?

At Wed, 2 Jun 2010 12:03:30 -0600,
Clinton Blackmore wrote:
> 
> Would it be easier to bring Scratch forward to run on a newer version of Squeak?

  Hmm, I think that would be so much more work, compared to for
example bringing in the InterpreterSimulator into the Scratch image.

-- Yoshiki

> On Wed, Jun 2, 2010 at 11:55 AM, Yoshiki Ohshima <yoshiki <at> vpri.org> wrote:
> 
>     At Fri, 28 May 2010 10:55:31 -0600,
>     Clinton Blackmore wrote:
>     >
>     > Very interesting.  It looks like I will probably not get to try any of these methods until next week, but, what
>     sort of
>     > adjustments do you think it would need for Scratch images?
>    
>     The biggest single issue is that my ImageBrowser depends on
>     InterpreterSimulator to load the image file and find out the object
>     pointers in it. An older version of InterpreterSimulator that is
>     suitable for the Scratch image can be found somewhere (like in the
>     Squeak2.4 image) but bringing in it will take some efforts.
>    
>     -- Yoshiki
>     _______________________________________________
>     Beginners mailing list
>     Beginners <at> lists.squeakfoundation.org
>     http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 
> 
> [2  <text/plain; us-ascii (7bit)>]
> _______________________________________________
> Beginners mailing list
> Beginners <at> lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
Clinton Blackmore | 2 Jun 2010 21:26
Picon

Re: How do I diff two images?

Fair enough.


Clinton

On Wed, Jun 2, 2010 at 12:16 PM, Yoshiki Ohshima <yoshiki <at> vpri.org> wrote:
At Wed, 2 Jun 2010 12:03:30 -0600,
Clinton Blackmore wrote:
>
> Would it be easier to bring Scratch forward to run on a newer version of Squeak?

 Hmm, I think that would be so much more work, compared to for
example bringing in the InterpreterSimulator into the Scratch image.

-- Yoshiki

> On Wed, Jun 2, 2010 at 11:55 AM, Yoshiki Ohshima <yoshiki <at> vpri.org> wrote:
>
>     At Fri, 28 May 2010 10:55:31 -0600,
>     Clinton Blackmore wrote:
>     >
>     > Very interesting.  It looks like I will probably not get to try any of these methods until next week, but, what
>     sort of
>     > adjustments do you think it would need for Scratch images?
>
>     The biggest single issue is that my ImageBrowser depends on
>     InterpreterSimulator to load the image file and find out the object
>     pointers in it. An older version of InterpreterSimulator that is
>     suitable for the Scratch image can be found somewhere (like in the
>     Squeak2.4 image) but bringing in it will take some efforts.
>
>     -- Yoshiki
>     _______________________________________________
>     Beginners mailing list
>     Beginners <at> lists.squeakfoundation.org
>     http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
> [2  <text/plain; us-ascii (7bit)>]
> _______________________________________________
> Beginners mailing list
> Beginners <at> lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Sean P. DeNigris | 4 Jun 2010 00:46
Gravatar

How can I prevent a new Morph from being stepped?


My TextMorph subclass's>>step seems to be getting called before the object is
ready - or at least that's what I pieced together from stepping through the
debugger.

I tried adding the following to initialize :
	self stop.
	self stopStepping.
But step is still called.

Can I prevent the object from being stepped out of the gate, until I turn
stepping on later?

Here is the code:  http://forum.world.st/file/n2242459/MorphicSPD-spd.1.mcz
MorphicSPD-spd.1.mcz 
To cause the error, Doit: GrowableTextMorph new openInWorld.
The specific error is: 'UndefinedObject(Object)>>doesNotUnderstand:
#withIndexDo:'

Thanks.
Sean
--

-- 
View this message in context: http://forum.world.st/How-can-I-prevent-a-new-Morph-from-being-stepped-tp2242459p2242459.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
Bert Freudenberg | 4 Jun 2010 00:48
Picon
Gravatar

Re: How can I prevent a new Morph from being stepped?


On 04.06.2010, at 00:46, Sean P. DeNigris wrote:

> 
> Can I prevent the object from being stepped out of the gate, until I turn
> stepping on later?

Have wantsSteps return false.

Then you can start stepping later.

- Bert -
Sean P. DeNigris | 4 Jun 2010 00:57
Gravatar

Re: How can I prevent a new Morph from being stepped?


Bert Freudenberg wrote:
> 
> Have wantsSteps return false.
> 

Awesome, worked like a charm.  Thanks, Bert.

Sean
--

-- 
View this message in context: http://forum.world.st/How-can-I-prevent-a-new-Morph-from-being-stepped-tp2242459p2242466.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.

Gmane