[clean-list] Process starting

Arjen van Weelden A.vanWeelden at cs.ru.nl
Wed Mar 8 16:18:17 MET 2006


Hernyák Zoltán wrote:
> Hi,
> 
>> Object I/O processes do not run in different threads/processes, so 
>> that will not work as you might expect.
> 
> Let's suppose, I want to write a consumer-producer -like application.
> The main thread would be the consumer, while an other process would
> be the producer. So there is no way to start on separate threads?

Not using Object I/O as it is implemented at the moment.

>>
>> Why don't you just create two programs (or one program that does two 
>> things depending on its command line arguments), and start them both 
>> using a script/batch file.
> Because my task is to write programs which sends and receives data from 
> outside.
> This is a kind of port-reading-writing problems, where on the other side 
> a 3rd party
> program processes the data elements.
> 
> The main program is a kind of:
> 
> Start w =
>    #! w = sendAllData [1...10000] w
>    #! (result,w) = receiveAllData w
>   = result
> 
> This cannot work, because until all the elements of [1..1000] is not 
> sended,
> nothing is received. Let suppose, the 3rd party program reads one data 
> element from the
> port, and sends it back immediately on a synchronized way. So until the 
> succesfull receiving it won't
> read another data element from the port. The only idea is to solve is that:
> 
> Start w =
>    #! w = sendAllData_OnSeparateThread [1...10000] w
>    #! (result,w) = receiveAllData w
>   = result
> 
> So it can't be solved in Clean?? I barely think that :)
> 
> Zoltan Hernyak

It still looks as if two separate programs, or a single program started 
twice, could solve your problem, in combination with a TCP/IP library.

Anyway, the example I sent you can be combined with Clean's TCP/IP 
library to do just that. The TCP/IP library, which is part of Object 
I/O, can also be used without Object I/O. Just select an unused port and 
setup a server in the main thread that receives data from the separate 
thread/process client. Take a look at ...Clean 2.1.1\Examples\Tcp 
Examples\chat\chat{Client|Server}.icl. This can easily be incorporated 
into the example containing newProcess that I sent you.

regards,
	Arjen

(one more thing: don't use so many #!'s, they are hardly ever necessary)




More information about the clean-list mailing list