Fork me on GitHub
#yada
<
2016-02-24
>
malcolmsparks07:02:18

@ericfode can you show me the value of media-type?

stijn08:02:03

@mccraigmccraig: in this case order doesn't matter indeed, so the callbacks that put onto a stream would work.

stijn08:02:26

I think if you want to preserve order and want to control the parallelism on a stream you'd need to implement something like https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L470

stijn08:02:35

(defn get-stuff 
  [x]
  (d/future
    (println (str "Getting " x))
    (Thread/sleep 1000) 
    (inc x)))

(def executor (executor/fixed-thread-executor 1))

(time (->> (stream/->source (range 20))
           (stream/onto executor)
           (stream/map get-stuff)
           (stream/map deref)
           (stream/consume println)))
=> Getting 0
Getting 1
1Getting 2

Getting 3
2
3
Getting 4
Getting 5
4
5
Getting 6
Getting 7
...
"Elapsed time: 10042.600795 msecs"

stijn08:02:41

if the executor is a fixed-thread-executor 20, same result. it always takes 2 at a time.

stijn08:02:16

as I understand it from the docs: > execute-pool - Used to execute manifold.deferred/future bodies, and only created if that macro is used. This is an instrumented pool, and statistics can be consumed via manifold.executor/register-execute-pool-stats-callback.

stijn08:02:41

I would think that increasing the number of threads would increase the number of futures being evaluated

ericfode18:02:25

figured it out, i was mocking my request improporly

malcolmsparks18:02:53

Really? I'm glad you worked it out.

malcolmsparks18:02:23

Sorry for the delay in responding, work priorities got in the way

ericfode21:02:07

No problem simple_smile I appreciate that you are available at all :thumbsup: