Parallel iterator in Scala

前端 未结 4 1016
自闭症患者
自闭症患者 2020-12-06 00:43

Is it somehow possible, using Scala\'s parallel collections to parallelize an Iterator without evaluating it completely beforehand?

Here I am t

4条回答
  •  执笔经年
    2020-12-06 01:36

    From the ML, Traversing iterator elements in parallel:

    https://groups.google.com/d/msg/scala-user/q2NVdE6MAGE/KnutOq3iT3IJ

    I moved off Future.traverse for a similar reason. For my use case, keeping N jobs working, I wound up with code to throttle feeding the execution context from the job queue.

    My first attempt involved blocking the feeder thread, but that risked also blocking tasks which wanted to spawn tasks on the execution context. What do you know, blocking is evil.

提交回复
热议问题