Fork me on GitHub
#clojure-europe
<
2022-03-25
>
dharrigan07:03:25

Good Morning!

ordnungswidrig07:03:29

Good morning in the morning!

mccraigmccraig07:03:52

anyone seen any prior art around concurrency limiting a function's application ? i need to wrap a function like (limit-conc n f) -> f' such that f' can be called just like f but will limit the concurrent applications of f...

ordnungswidrig07:03:53

What shall happen if the limit is reached?

mccraigmccraig07:03:03

park until some ongoing applications have finished - this is all promise-based, so concurrent-applications is equivalent to unresolved-promises

mccraigmccraig07:03:56

i think i'll need a queue of requested applications and some structure of active applications

mccraigmccraig07:03:48

and i need it on both clj+cljs ... and not sure of the best structures off the top of my head

mccraigmccraig07:03:15

or if i can pick up a lib and avoid writing the code 😬

otfrom08:03:01

sounds a bit like claypoole?

mccraigmccraig08:03:45

hmm - that's could be worth a look @U0525KG62 - the structures required may be similar (although claypoole is clj only and explicitly threadpool-based, so i can't actually use it)

otfrom08:03:53

some sort of token pool might do the same I suppose?

otfrom08:03:01

can't work unless you've got the working token?

ordnungswidrig09:03:18

It'd submit to a fixed worker pool, for java Executors/newFixedThreadPool in js maybe some like https://github.com/josdejong/workerpool

Ben Sless10:03:53

You can wrap it with a semaphore then not have to worry about where the function is running

ordnungswidrig12:03:25

In clojurescript?

Ben Sless12:03:46

Ah, woops. You can implement a semaphore with channels

mccraigmccraig09:03:07

giving up on this... i did an implementation, but it wasn't much faster than using a manifold stream with a buffer to control concurrency, and since it's for a streams lib i'm just going to munge streams instead

genRaiy08:03:00

Good morning

javahippie13:03:43

Morning!

😍 1
reefersleep13:03:29

Good morning 🙂 Sunny and windy here. Looking forward to see the sun wane and be left with cozy, windy darkness 💨