It's a shame the CSP style of tackling parallel programming hasn't caught on more. The Bell Labs guys know how to do this, see their languages Alef and Limbo. Channels, message passing, etc. Also, a UK university used to have some nice slides about doing the same thing in Occam, including an O(1) "sort pump". They all inherit the concept from Hoare's CSP. Perhaps now some of them, rob, ken, etc., have moved to Google we'll see a resurgence with it.