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

Added withDeadline modifier #7299

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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 @@ -287,6 +287,17 @@ public SequentialCommandGroup andThen(Command... next) {
return group;
}

/**
* Creates a new command that runs this command and the deadline in parallel, finishing when the
* deadline finishes.
*
* @param deadline the deadline of the command group
* @return the decorated command
*/
rzblue marked this conversation as resolved.
Show resolved Hide resolved
public ParallelDeadlineGroup withDeadline(Command deadline) {
return new ParallelDeadlineGroup(deadline, this);
}

/**
* Decorates this command with a set of commands to run parallel to it, ending when the calling
* command ends and interrupting all the others. Often more convenient/less-verbose than
Expand Down
rzblue marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static Command repeatingSequence(Command... commands) {
* @return the command
* @see ParallelCommandGroup
*/
public static Command parallel(Command... commands) {
public static ParallelCommandGroup parallel(Command... commands) {
return new ParallelCommandGroup(commands);
}

Expand All @@ -254,7 +254,7 @@ public static Command parallel(Command... commands) {
* @return the command group
* @see ParallelRaceGroup
*/
public static Command race(Command... commands) {
public static ParallelRaceGroup race(Command... commands) {
return new ParallelRaceGroup(commands);
}

Expand All @@ -268,7 +268,7 @@ public static Command race(Command... commands) {
* @see ParallelDeadlineGroup
* @throws IllegalArgumentException if the deadline command is also in the otherCommands argument
*/
public static Command deadline(Command deadline, Command... otherCommands) {
public static ParallelDeadlineGroup deadline(Command deadline, Command... otherCommands) {
return new ParallelDeadlineGroup(deadline, otherCommands);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ CommandPtr Command::OnlyIf(std::function<bool()> condition) && {
return std::move(*this).ToPtr().OnlyIf(std::move(condition));
}

CommandPtr Command::WithDeadline(CommandPtr&& deadline) && {
return std::move(*this).ToPtr().WithDeadline(std::move(deadline));
}

CommandPtr Command::DeadlineFor(CommandPtr&& parallel) && {
return std::move(*this).ToPtr().DeadlineFor(std::move(parallel));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ CommandPtr CommandPtr::OnlyIf(std::function<bool()> condition) && {
return std::move(*this).Unless(std::not_fn(std::move(condition)));
}

CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && {
AssertValid();
return std::move(deadline).DeadlineFor(std::move(*this));
Daniel1464 marked this conversation as resolved.
Show resolved Hide resolved
}

CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && {
AssertValid();
std::vector<std::unique_ptr<Command>> vec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,16 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
[[nodiscard]]
CommandPtr OnlyIf(std::function<bool()> condition) &&;

/**
* Creates a new command that runs this command
* and the deadline in parallel, finishing when
* the deadline finishes.
*
* @param deadline the deadline of the command group
* @return the decorated command
*/
rzblue marked this conversation as resolved.
Show resolved Hide resolved
CommandPtr WithDeadline(CommandPtr&& deadline) &&;

/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the calling command ends and interrupting all the others. Often more
Expand All @@ -321,6 +331,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
*/
[[nodiscard]]
CommandPtr DeadlineFor(CommandPtr&& parallel) &&;

/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the last command ends. Often more convenient/less-verbose than
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ class CommandPtr final {
[[nodiscard]]
CommandPtr OnlyIf(std::function<bool()> condition) &&;

/**
* Creates a new command that runs this command
* and the deadline in parallel, finishing when
* the deadline finishes.
rzblue marked this conversation as resolved.
Show resolved Hide resolved
*
* @param deadline the deadline of the command group
* @return the decorated command
*/
CommandPtr WithDeadline(CommandPtr&& deadline) &&;

/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the calling command ends and interrupting all the others. Often more
Expand Down
Loading