-
Notifications
You must be signed in to change notification settings - Fork 611
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 |
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
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 |
Thank you! |
/format |
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
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
This will need conflicts resolved from #5461 - let us know if you need help with that. |
Squashed everything down and rebased; should be good to go! |
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.