how to efficiently apply a medium-weight function in parallel

前端 未结 4 610
广开言路
广开言路 2020-12-30 07:51

I\'m looking to map a modestly-expensive function onto a large lazy seq in parallel. pmap is great but i\'m loosing to much to context switching. I think I need

4条回答
  •  萌比男神i
    2020-12-30 08:02

    I would look at the Fork/Join library, set to be integrated into JDK 7. It's a lightweight threading model optimized for nonblocking, divide-and-conquer computations over a dataset, using a thread pool, a work-stealing scheduler and green threads.

    Some work has been done to wrap the Fork/Join API in the par branch, but it hasn't been merged into main (yet).

提交回复
热议问题