[vwnc] Question about procesess

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

[vwnc] Question about procesess

Andres Fortier-2
Hi list,
            I have a typical situation of getting
data/processing/sending data, running in a constant loop. Both the
input and output are done via sockets. The code looks something like:


MyClass>>step

                | data result |

                data:=self input readData.
                result:=self process: data.
                self output send: result.


where readData uses at some place something like:

                self socket readWait.

Now, I would like to add some sort of play/stop functionality. I've
seen that I can fork a process that constantly calls #step and store
the process in an inst var, so I can later send something like
#terminate to it. However there are two issues that I'm not sure about:

1. I know that if I send the #terminate message while the process is
in the socket's #readWait, the process actually stops; what I would
like to know is if this is safe in terms of the socket (i.e. if I'm
not eaving something at the vm or os level in an inconsistent state).
2. If the data has already been read from the socket I would like the
step to end (i.e. the data processing and the send to be completed,
kind of a transaction). Is there any simple way of handling this?

Thanks in advance,
                                Andrés
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about procesess

Terry Raymond
Andres

If you look at IOAccessor>>readWaitWithTimeoutMs: you will
see that the Delay shares the read semaphore. So, when
the delay signals the semaphore the read process will awaken.

You can do something similar. When you want to terminate
you set a terminate flag then signal the semaphore. The
read process then reads whatever is there and continues
the read loop, which checks the terminate flag at the
end of the read processing.

Terry
 
===========================================================
Terry Raymond
Crafted Smalltalk
80 Lazywood Ln.
Tiverton, RI  02878
(401) 624-4517      [hidden email]
<http://www.craftedsmalltalk.com>
===========================================================

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Andres Fortier
> Sent: Friday, November 21, 2008 12:33 PM
> To: VWNC List
> Subject: [vwnc] Question about procesess
>
> Hi list,
>             I have a typical situation of getting
> data/processing/sending data, running in a constant loop. Both the
> input and output are done via sockets. The code looks something like:
>
>
> MyClass>>step
>
> | data result |
>
> data:=self input readData.
> result:=self process: data.
> self output send: result.
>
>
> where readData uses at some place something like:
>
> self socket readWait.
>
> Now, I would like to add some sort of play/stop functionality. I've
> seen that I can fork a process that constantly calls #step and store
> the process in an inst var, so I can later send something like
> #terminate to it. However there are two issues that I'm not sure about:
>
> 1. I know that if I send the #terminate message while the process is
> in the socket's #readWait, the process actually stops; what I would
> like to know is if this is safe in terms of the socket (i.e. if I'm
> not eaving something at the vm or os level in an inconsistent state).
> 2. If the data has already been read from the socket I would like the
> step to end (i.e. the data processing and the send to be completed,
> kind of a transaction). Is there any simple way of handling this?
>
> Thanks in advance,
> Andrés
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about procesess

Andres Fortier-2
Thanks Terry, that sounds good! I'll look into it.

Cheers,
              Andrés

Terry Raymond escribió:

> Andres
>
> If you look at IOAccessor>>readWaitWithTimeoutMs: you will
> see that the Delay shares the read semaphore. So, when
> the delay signals the semaphore the read process will awaken.
>
> You can do something similar. When you want to terminate
> you set a terminate flag then signal the semaphore. The
> read process then reads whatever is there and continues
> the read loop, which checks the terminate flag at the
> end of the read processing.
>
> Terry
>  
> ===========================================================
> Terry Raymond
> Crafted Smalltalk
> 80 Lazywood Ln.
> Tiverton, RI  02878
> (401) 624-4517      [hidden email]
> <http://www.craftedsmalltalk.com>
> ===========================================================
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On Behalf Of Andres Fortier
>> Sent: Friday, November 21, 2008 12:33 PM
>> To: VWNC List
>> Subject: [vwnc] Question about procesess
>>
>> Hi list,
>>             I have a typical situation of getting
>> data/processing/sending data, running in a constant loop. Both the
>> input and output are done via sockets. The code looks something like:
>>
>>
>> MyClass>>step
>>
>> | data result |
>>
>> data:=self input readData.
>> result:=self process: data.
>> self output send: result.
>>
>>
>> where readData uses at some place something like:
>>
>> self socket readWait.
>>
>> Now, I would like to add some sort of play/stop functionality. I've
>> seen that I can fork a process that constantly calls #step and store
>> the process in an inst var, so I can later send something like
>> #terminate to it. However there are two issues that I'm not sure about:
>>
>> 1. I know that if I send the #terminate message while the process is
>> in the socket's #readWait, the process actually stops; what I would
>> like to know is if this is safe in terms of the socket (i.e. if I'm
>> not eaving something at the vm or os level in an inconsistent state).
>> 2. If the data has already been read from the socket I would like the
>> step to end (i.e. the data processing and the send to be completed,
>> kind of a transaction). Is there any simple way of handling this?
>>
>> Thanks in advance,
>> Andrés
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc