-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Simplify Executor.acquire #267
Conversation
Another wonderful PR, I can't not express how much I love this kind PR! Really appreciate! I read each commit carefully, I think they're correct and beautiful. It is just I'll be more confident if we have some tests for this logic. Is this something you would like to try? If you don't I'll try to write some tests before merging this. Don't hesitate if you have any question. |
* master: Fix type confg => config
I was trying to write some test, but stuck up with |
We can start with testing the logic inside |
Oh, now I can see that we can provide moves directly through |
Forgot to mention this, We don't really need to care about that case. All we need is eventually all works will be acquirred. |
@lenguyenthanh sorry, I am too busy with studying and contributing for Cats (if Cats-PR got merged, I will push another PR here, sometime), would not be able to write tests any time soon |
no worries @Masynchin, good luck on your cats's pr. Would always welcome your PRs! |
Same aim as in #266.
First, I extracted filtering logic from pattern match by applying
filter
method before, which also simplified pattern match to 1 case arm. Next I replacedfoldLeft[Option]
byreduceLeftOption
, a little cleaner, but logic exact the same. And finally, I noticed that after filtering works with_.nonAcquired
, them.canAcquire(key)
part of if-statement inside always evaluates totrue
because of theWork.Move
implementation:https://github.com/Masynchin/lila-fishnet/blob/2135cb36973495e55bc8909710063e7f388959e5/app/src/main/scala/Work.scala#L34-L36
So,
reduce
's if-statement shortens tom.createdAt.isBefore(a.createdAt)
, which is just comparing who created earliest. Only thing I don't know what is the logic when twoMove
'screatedAt
equals, or can it be at all