parallel collections?  

  RSS

dckc
 dckc
(@dckc)
Member Moderator
Joined:5 months  ago
Posts: 20
06/06/2018 3:02 am  

The iteration and matching section of the tutorial shows iterating through a list -- sequentially.

Any suggestion on how to exploit Rholang concurrency?

I can imagine map and reduce with code duplicated 4x to get 4x parallelism and so on, but that seems kinda ugly.

 

 


ReplyQuote
MichaelBirch
(@michaelbirch)
Member Moderator
Joined:6 months  ago
Posts: 38
06/06/2018 1:10 pm  

The key aspect of the iteration which makes it sequential is that on line 7 a `for` blocks the loop from continuing until the current iteration is complete. If there was no such block then the loop would essentially unroll all at once and you would get fully concurrent execution on the list. That's the beauty of Rholang -- it's concurrent by default and you need to actively try to make it sequential.


ReplyQuote
dckc
 dckc
(@dckc)
Member Moderator
Joined:5 months  ago
Posts: 20
06/06/2018 1:15 pm  

Oh... That example is doing foreach... But what about map or flatmap? That is: how do I get the results back into a list? Or map?


ReplyQuote
MichaelBirch
(@michaelbirch)
Member Moderator
Joined:6 months  ago
Posts: 38
06/06/2018 9:22 pm  

One way of doing it would be to have all the concurrent processes send their results to the same contract, which accumulates them in the structure you want.


ReplyQuote
  
Working

Please Login or Register