开发者

interaction between seque and pmap

If I pmap a开发者_C百科 function onto a sequence how far ahead will the sequence be realised in parallel If I have a single thread reading from a sequence being produced in parallel?

will this be different if I wrap it in a seque:

(seque 30 (pmap do-stuff (range 30000)))

vs.

(pmap do-stuff (range 30000))


pmap provides no guarantees of how far ahead it will read on it's input sequence - presumably, not too much farther than what it needs to do its calculation.

(seque 30 ...) will realize and cache up to 30 elements from pmap's output sequence. That must logically be at least the first 30 from the input sequence. How far beyond that I can't say without looking at the implementation of pmap, which you probably ought not to depend upon.

I'm curious why you need to know this. The details of when a function executes, particularly in a pmap, are something you usually want abstracted away. If it's curiosity, great. But if you're depending on some side effect of the do-stuff function, you're Doing It Wrong(tm).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜