Skip to main content

Timeline for Concurrent map/foreach in scala

Current License: CC BY-SA 2.5

8 events
when toggle format what by license comment
Oct 17, 2019 at 17:24 comment added Danny Varod Any insight on what to use now that that library is deprecated?
Aug 5, 2014 at 14:24 comment added Jus12 What does it mean when you say it "returns asynchronously"? Does it imply that it is non-blocking? (and why would that be a problem?)
Nov 22, 2009 at 2:01 comment added Daniel Spiewak You're right, foreach was (obviously) the wrong thing to inject since it returns Unit. My bad! :-) The map function on lazy collections is almost always non-strict, so we can either call toList (or toArray), or we can project and then force: (vals map { x => future { f(x) } } projection).force foreach { _() }. I don't know whether that's better than simply toList, but it is certainly different.
Nov 20, 2009 at 22:50 comment added David Crawshaw That would be a map we have to inject, not another foreach? And it is not clear to me that the map of a lazy collection is strict. The safest way may be to call toArray.
Nov 20, 2009 at 22:45 vote accept David Crawshaw
Nov 18, 2009 at 15:43 comment added Daniel Spiewak I suppose we could solve that problem by injecting another foreach call between the map and the current foreach. Thus: vals map { x => future { f(x) } } foreach { x => x } foreach { _() }
Nov 18, 2009 at 5:34 comment added Ken Bloom Be careful that vals is a strict collection -- if it's lazy (and in Scala 2.7 this includes the Range class), the futures won't be created until each one is needed by foreach, and nothing will happen in parallel.
Nov 18, 2009 at 2:24 history answered Daniel Spiewak CC BY-SA 2.5