-
Notifications
You must be signed in to change notification settings - Fork 606
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
Make command scheduling order consistent #5470
Make command scheduling order consistent #5470
Conversation
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
Also, the most important thing this PR should be adding is tests. Any possible edge case should be added and tested on both new and old impls; if there are differences they should be exactly what we want. |
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
I just realized that SchedulingRecursionTest.cancelFromInitialize doesn't check if |
e2267f8
to
8e93516
Compare
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
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.
Glad to see more consistency! However, I have a few nitpicks (in addition to updating the PR description).
wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java
Outdated
Show resolved
Hide resolved
84254c9
to
7bebaf3
Compare
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
Getting an error for the What's causing it? |
Probably concurrent modification. |
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
The Requirements are being transferred before the command actually ends; this seems to cause a problem for C++, and also might be problematic in general. However, the command is guaranteed to be canceled, so this might be fine to leave in. The test also passes in |
Things have gotten kind of thorny, so I tried completely rethinking the whole thing, and here's the proposal I have: Instead of dealing with the queue headaches, use a set to keep track of which commands are currently ending to detect and prevent infinite recursion. In more detail:
Notes:
|
Using a set works, but I'm still getting that invalid iterator access error on C++, and I don't know how to fix it. |
After tracking the problem to |
6d3bacb
to
53eb2df
Compare
Thank you! |
/format |
48c86d8
to
0ab2c4a
Compare
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp
Outdated
Show resolved
Hide resolved
aee5266
to
8ff90fb
Compare
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.
Besides that nitpick and the cancel() deduplication, should be good to go.
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java
Outdated
Show resolved
Hide resolved
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 good to me, except for this one change.
wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp
Outdated
Show resolved
Hide resolved
29ccf90
to
bc68351
Compare
bc68351
to
11f56b5
Compare
37dfa07
to
0f8133b
Compare
0f8133b
to
286fac3
Compare
286fac3
to
13a079a
Compare
This will need conflicts resolved from #5461 - let us know if you need help with that. |
13a079a
to
4317ba1
Compare
Squashed everything down and rebased; should be good to go! |
dc38fad
to
6fa1ff3
Compare
6fa1ff3
to
3672929
Compare
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 good to me. We need to keep an eye on this one during beta to ensure no unexpected breakages occur.
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.
Hopefully this won't break anything.
Fixes #5467.
end
is now called first along with interrupt actions on both languages. Sets are used to defer cancels, ensuring infinite loops aren't possible.