Skip to content

Commit

Permalink
[commands] Add a warning to schedule javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Sep 28, 2024
1 parent 32252f7 commit 6eb9b24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ private void initCommand(Command command, Set<Subsystem> requirements) {
* using those requirements have been scheduled as interruptible. If this is the case, they will
* be interrupted and the command will be scheduled.
*
* WARNING: using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands.
*
* @param command the command to schedule. If null, no-op.
*/
private void schedule(Command command) {
Expand Down Expand Up @@ -230,6 +232,8 @@ private void schedule(Command command) {
/**
* Schedules multiple commands for execution. Does nothing for commands already scheduled.
*
* WARNING: using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands.
*
* @param commands the commands to schedule. No-op on null.
*/
public void schedule(Command... commands) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace frc2 {
class Command;
class CommandPtr;
class Subsystem;

/**
* The scheduler responsible for running Commands. A Command-based robot should
* call Run() on the singleton instance in its periodic block in order to run
Expand Down Expand Up @@ -88,6 +87,8 @@ class CommandScheduler final : public wpi::Sendable,
* interruptible. If this is the case, they will be interrupted and the
* command will be scheduled.
*
* @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands.
*
* @param command the command to schedule
*/
void Schedule(const CommandPtr& command);
Expand All @@ -99,6 +100,8 @@ class CommandScheduler final : public wpi::Sendable,
* scheduled as interruptible. If this is the case, they will be interrupted
* and the command will be scheduled.
*
* @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands.
*
* @param command the command to schedule
*/
void Schedule(Command* command);
Expand All @@ -107,6 +110,8 @@ class CommandScheduler final : public wpi::Sendable,
* Schedules multiple commands for execution. Does nothing for commands
* already scheduled.
*
* @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands.
*
* @param commands the commands to schedule
*/
void Schedule(std::span<Command* const> commands);
Expand All @@ -115,6 +120,8 @@ class CommandScheduler final : public wpi::Sendable,
* Schedules multiple commands for execution. Does nothing for commands
* already scheduled.
*
* @warning Using this function directly is often a footgun and should be avoided. Instead Triggers should be used to schedule Commands.
*
* @param commands the commands to schedule
*/
void Schedule(std::initializer_list<Command*> commands);
Expand Down

0 comments on commit 6eb9b24

Please sign in to comment.