Hi: On 14 Jun 2012, at 11:34, Frank Shearar wrote:
How do you #join Processes? I can't see anything in Process' protocol for doing so. so what am I missing?
Nothing. Theres no support for join. You have to roll your own.
OK, that's what I thought. Stefan's comment intrigued me.
Yes, my fault. I added it to some random subclass somewhere, because I thought it was handy. It is indeed not in the standard images.
It would be kind've handy to be able to say - even though we don't use native threads - something like this:
(0..10).map {|i| Thread.new { sleep(1); i } }.map {|t| t.value}
only in a decent language:
((0 to: 10) collect: [:i | [(Delay forSeconds: 1) wait. i] fork]) collect: [:p | p value].
Yes, that was part of the discussion. For the options discussed of the return value of fork, we have three options: 1. self [Smalltalk-80 defines it this way, apparently] self is the block, it is the consistent return value for methods without real return value. -> I think, this is the least useful option 2. Process [current implementation] It's the object created as the side-effect of fork. Allows to query whether the fork already completed. Process could be extended to offer #join (at a cost of a semaphore, presumably). 3. Promise As the placeholder for the result value of the block computation. Benefit is that we get an immediate handle on the result, and the ability to wait for the completion of the process, even if we only care for its side-effects. There is however currently no Promise class in Pharo. Squeak got one, I think. Best regards Stefan -- Stefan Marr Software Languages Lab Vrije Universiteit Brussel Pleinlaan 2 / B-1050 Brussels / Belgium http://soft.vub.ac.be/~smarr Phone: +32 2 629 2974 Fax: +32 2 629 3525