New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature - a concurrency limiter #22
Conversation
038722a
to
793dd80
Compare
return future; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding missing newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
+1 Very nice, this will come in handy. |
793dd80
to
11b03af
Compare
Looks good, a couple of questions, though:
|
@pettermahlen Thanks for the comments. I pushed some new commits which leads to:
|
final SettableFuture<T> response = SettableFuture.create(); | ||
final Job<T> job = new Job<T>(callable, response); | ||
if (queueSize.get() >= maxQueueSize) { | ||
throw new CapacityReachedException("Queue size has reached capacity: " + maxQueueSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like mixing sync exc with async exc.
I'm a bit unsure if the calls to It might be OK from a cpu utilization view since the callables should return immediatly, but can cause confusion for other surprising reasons. |
Yes, callables will indeed run on seemingly random threads. I don't think this is enough of a problem to block releasing the feature. If it turns out to be a real problem we can create a new API that lets people pass in an executor to run on. |
New feature - a concurrency limiter
No description provided.