rate-gate icon indicating copy to clipboard operation
rate-gate copied to clipboard

Modify rate-gate to use future instead of a separate thread

Open osbert opened this issue 12 years ago • 3 comments

This has the following benefits:

Does not require separate Thread creation per function rate-gated, which can be an issue if you wish to rate-gate lots of functions independently of one another. Instead, we utilize the thread pool that futures execute on.

Simplifies RateGate object by eliminating list of exit times and thread object. Reduces usage of Java objects, preferring Clojure-isms instead. Removes unnecessary extra logic associated as well.

osbert avatar Jun 18 '13 16:06 osbert

Yes, your argument does make sense. I was trying to figure out a way to wrap a large number of functions without requiring a thread per rate-gate, and I was under the impression that futures utilized a fixed sized thread-pool (which it does not). Although now I believe/realize having a shared monitoring thread does have it's own set of complications that breaks the desired semantics. Thanks, back to the drawing board.

osbert avatar Jun 18 '13 17:06 osbert

I have tried again, this time using core.async. Of course, it may not make sense to pull in for now since core.async is still only a SNAPSHOT release, but I believe it accomplishes what I was originally hoping to do. It does not require an explicit management thread per function rate-gated, nor does it create a thread per function call, and includes tests to attempt to verify that this is true.

osbert avatar Jul 10 '13 04:07 osbert

Hi @osbert - thanks for sending an update. Would you like commit access to this repo? I honestly haven't looked at this lib in a long time and won't be able to review or provide much help.

jkk avatar Oct 17 '17 18:10 jkk