Fork me on GitHub
#core-async
<
2017-05-04
>
mbjarland13:05:29

a question about pipeline-async. It says in the docs (https://clojure.github.io/core.async/#clojure.core.async/pipeline-async) that: A: af must be a function of two arguments, the first an input value and the second a channel on which to place the result(s) B: af must close! the channel before returning C: the presumption is that af will return immediately, having launched some asynchronous operation (i.e. in another thread) whose completion/callback will manipulate the result channel isn't this somewhat contradictory? Af should return immediately and make sure to close the result channel before it does so...but the result will be calculated asynchronously and might take time to compute...how do we both "return immediately" and "produce result on the channel later"? I think I'm missing something fundamental here...

tbaldridge13:05:17

no the call to close! should happen some time later whenever the async operation called by af has finished

tbaldridge13:05:53

the point of af @mbjarland is to fire off some sort of async thask, then af returns, and sometime in the future data will be put onto the chan and then the chan will be closed.

mbjarland13:05:13

so isn't B above incorrect then? (and apologies for potentially being a bit thick here)...

tbaldridge13:05:28

yes, B is incorrect

mbjarland13:05:47

ok, glad to hear I'm not going crazy. The above is straight from the docs, there might be room for improving the wording in the docs it seems

mbjarland13:05:17

@tbaldridge thanks for the clarification