-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
refactor+perf(study-screen): custom scheduler #19950
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
base: main
Are you sure you want to change the base?
Conversation
3550914 to
c1c06f6
Compare
david-allison
left a comment
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.
Soft approve
| while (!statesMutated) { | ||
| delay(50) | ||
| } | ||
| mutationSignal.await() |
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.
Likely off-topic & could be moved to another issue.
I'm concerned there's no cancellation support.
What happens when a card is flipped, but this hasn't run yet? What if there's an error, or the code is slow?
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.
Functionally, the only difference in comparison with the previous approach is how it waits for the signal, i.e. while...delay(50) vs CompletableDeferred.await().
Should it have some kind of timeout instead of waiting indefinitely? Perhaps.
Is the custom scheduler logic convoluted? Yes. And that is a consequence of how Anki desktop is architectured. I'm mostly following how the desktop version make the reviewer work, even in a barely used setting like this one.
ReviewerFragmentTest tests if the custom scheduler is working, so that is covered.
Making the logic safer to future refactors need some integration tests, and I'm still far from them.
So, create another issue if you want. Or simply wait until this turns into a problem (or not).
also made it use its ConfigKey constant
1. latency is better (e.g. if the JS code finishes 1ms after a check, it doesn't need to wait 49ms for a new check)
2. it's more efficient
3. it's cleaner
tested by adding `console.log("some message");` in the custom scheduler
c1c06f6 to
c6bab3b
Compare
david-allison
left a comment
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.
Wasn't expecting the infinite loops to be handled here, only flagging that they're an issue.
A TODO is probably the best call, it wouldn't meet 'priority: low' yet, but leaving that one up to you
Approach
In the commits
How Has This Been Tested?
Emulator 31:
console.log("some message");thereChecklist
Please, go through these checks before submitting the PR.