-
Notifications
You must be signed in to change notification settings - Fork 902
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
OrderedScheduler#chooseThread(key) handle null key #1372
Conversation
retest this please |
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.
+1
retest this please |
return threads[rand.nextInt(threads.length)]; | ||
} else { | ||
return threads[MathUtils.signSafeMod(orderingKey.hashCode(), threads.length)]; | ||
} |
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.
Looks fine, but wondering what is the usecase of this? I worry it might mask bugs as ordered safe executor is an absolute must to protect the correctness (wherever it is needed). So callers need to know what they are doing.
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.
it is for convenience, so in the caller, I don't have to do if (orderKey != null) chooseThread(orderKey); else chooseThread(..)
. I can have a separate util function to do that, but I feel it is better to do it at the executor level.
retest this please |
Descriptions of the changes in this PR: *Motivation* It is more convenient if OrderedScheduler#chooseThread(key) can handle null key. so the applications who is using #chooseThread don't need to worry which method to choose - `chooseThread()` vs `chooseThread(key)`. *Solution* in `chooseThread(key)`, fallback to randomly pickup a thread if key is null. Author: Sijie Guo <sijie@apache.org> Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Jia Zhai <None> This closes #1372 from sijie/order_scheduler_null_key (cherry picked from commit 1f0f92c) Signed-off-by: Sijie Guo <sijie@apache.org>
Descriptions of the changes in this PR: *Motivation* It is more convenient if OrderedScheduler#chooseThread(key) can handle null key. so the applications who is using #chooseThread don't need to worry which method to choose - `chooseThread()` vs `chooseThread(key)`. *Solution* in `chooseThread(key)`, fallback to randomly pickup a thread if key is null. Author: Sijie Guo <sijie@apache.org> Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Jia Zhai <None> This closes apache#1372 from sijie/order_scheduler_null_key (cherry picked from commit 1f0f92c) Signed-off-by: Sijie Guo <sijie@apache.org> Signed-off-by: JV Jujjuri <vjujjuri@salesforce.com>
Descriptions of the changes in this PR:
Motivation
It is more convenient if OrderedScheduler#chooseThread(key) can handle null key. so the applications who is using #chooseThread don't need to worry which method to choose -
chooseThread()
vschooseThread(key)
.Solution
in
chooseThread(key)
, fallback to randomly pickup a thread if key is null.