Delay, BlockClosure and Process

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Delay, BlockClosure and Process

Holger Freyther
Hi,

I am not seeing the light here...

Proc := [
   [true] whileTrue: [
       c_call_out.
       (Delay forMilliSeconds: 500) wait.
   ].
] fork

I would assume that c_call_out would be called every couple of milliseconds
but it appears that when the delay is over the Process just exits. Why is that
the case? How can I avoid it? How can I achieve something better? (well it
would be nice to avoid the poll all together but that is for later).

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Delay, BlockClosure and Process

Stefan Schmiedl
On Sat, 11 Sep 2010 01:37:36 +0800
Holger Hans Peter Freyther <[hidden email]> wrote:

> Hi,
>
> I am not seeing the light here...
>
> Proc := [
>    [true] whileTrue: [
>        c_call_out.
>        (Delay forMilliSeconds: 500) wait.
>    ].
> ] fork
>
> I would assume that c_call_out would be called every couple of milliseconds
> but it appears that when the delay is over the Process just exits. Why is that
> the case? How can I avoid it? How can I achieve something better? (well it
> would be nice to avoid the poll all together but that is for later).

Try running this code via gst-remote.

$1 gst-remote --server

$2 gst-remote --eval ' [ [true] whileTrue: [ 0 printNl. (Delay forSeconds: 1) wait ] ] fork'
$2 gst-remote --eval ' [ [true] whileTrue: [ 1 printNl. (Delay forSeconds: 1) wait ] ] fork'

output in $1:

gst-remote server started.
0
0
0
0
0
1
0
1
0
1
0
1

s.

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Delay, BlockClosure and Process

Paolo Bonzini-2
On Sat, Sep 11, 2010 at 00:11, Stefan Schmiedl <[hidden email]> wrote:
> Try running this code via gst-remote.

Or in VisualGST.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Delay, BlockClosure and Process

Nigel Williams-5
In reply to this post by Holger Freyther
On 11/09/2010, at 3:37 AM, Holger Hans Peter Freyther wrote:

> I would assume that c_call_out would be called every couple of milliseconds
> but it appears that when the delay is over the Process just exits. Why is that
> the case? How can I avoid it? How can I achieve something better? (well it
> would be nice to avoid the poll all together but that is for later).

If you're running that at the REPL (the st> prompt) and returning to the REPL, it won't work because the VM is not running while the REPL is waiting for input.

If you try "Processor activeProcess suspend" at the REPL you will return control to the process scheduler and your process should get run.

The reason gst-remote and visualgst should also work is that they're not sitting with the REPL waiting for input either.

Nigel
_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Delay, BlockClosure and Process

Holger Freyther
On 09/13/2010 09:31 AM, Nigel Williams wrote:

> On 11/09/2010, at 3:37 AM, Holger Hans Peter Freyther wrote:
>
>> I would assume that c_call_out would be called every couple of milliseconds
>> but it appears that when the delay is over the Process just exits. Why is that
>> the case? How can I avoid it? How can I achieve something better? (well it
>> would be nice to avoid the poll all together but that is for later).
>
> If you're running that at the REPL (the st> prompt) and returning to the REPL, it won't work because the VM is not running while the REPL is waiting for input.
>
> If you try "Processor activeProcess suspend" at the REPL you will return control to the process scheduler and your process should get run.
>
> The reason gst-remote and visualgst should also work is that they're not sitting with the REPL waiting for input either.



Thanks, I had used Paolo's trick to type stdin next, to yield the execution

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk