Skip to content
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

[cmd] Improve isScheduled to be more performant when checking a single command #7096

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,28 @@ public void cancelAll() {
* scheduled by the scheduler; it will not work on commands inside compositions, as the scheduler
* does not see them.
*
* @param commands the command to query
* @return whether the command is currently scheduled
* @param commands multiple commands to check
* @return whether all of the commands are currently scheduled
*/
public boolean isScheduled(Command... commands) {
return m_scheduledCommands.containsAll(Set.of(commands));
for (var cmd : commands) {
if (!isScheduled(cmd)) {
return false;
}
}
return true;
}

/**
* Whether the given commands are running. Note that this only works on commands that are directly
* scheduled by the scheduler; it will not work on commands inside compositions, as the scheduler
* does not see them.
*
* @param command a single command to check
* @return whether all of the commands are currently scheduled
*/
public boolean isScheduled(Command command) {
return m_scheduledCommands.contains(command);
}

/**
Expand Down
Loading