Skip to content

Commit 638d265

Browse files
authored
[commands] Add a warning to schedule docs (NFC) (#7073)
Signed-off-by: Jade Turner <[email protected]>
1 parent 6125227 commit 638d265

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ private void initCommand(Command command, Set<Subsystem> requirements) {
180180
* using those requirements have been scheduled as interruptible. If this is the case, they will
181181
* be interrupted and the command will be scheduled.
182182
*
183+
* <p>WARNING: using this function directly can often lead to unexpected behavior and should be
184+
* avoided. Instead Triggers should be used to schedule Commands.
185+
*
183186
* @param command the command to schedule. If null, no-op.
184187
*/
185188
private void schedule(Command command) {
@@ -230,6 +233,9 @@ private void schedule(Command command) {
230233
/**
231234
* Schedules multiple commands for execution. Does nothing for commands already scheduled.
232235
*
236+
* <p>WARNING: using this function directly can often lead to unexpected behavior and should be
237+
* avoided. Instead Triggers should be used to schedule Commands.
238+
*
233239
* @param commands the commands to schedule. No-op on null.
234240
*/
235241
public void schedule(Command... commands) {

wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class CommandScheduler final : public wpi::Sendable,
8888
* interruptible. If this is the case, they will be interrupted and the
8989
* command will be scheduled.
9090
*
91+
* @warning Using this function directly can often lead to unexpected behavior
92+
* and should be avoided. Instead Triggers should be used to schedule
93+
* Commands.
94+
*
9195
* @param command the command to schedule
9296
*/
9397
void Schedule(const CommandPtr& command);
@@ -112,6 +116,10 @@ class CommandScheduler final : public wpi::Sendable,
112116
*
113117
* The pointer must remain valid through the entire lifecycle of the command.
114118
*
119+
* @warning Using this function directly can often lead to unexpected behavior
120+
* and should be avoided. Instead Triggers should be used to schedule
121+
* Commands.
122+
*
115123
* @param command the command to schedule
116124
*/
117125
void Schedule(Command* command);
@@ -120,6 +128,10 @@ class CommandScheduler final : public wpi::Sendable,
120128
* Schedules multiple commands for execution. Does nothing for commands
121129
* already scheduled.
122130
*
131+
* @warning Using this function directly can often lead to unexpected behavior
132+
* and should be avoided. Instead Triggers should be used to schedule
133+
* Commands.
134+
*
123135
* @param commands the commands to schedule
124136
*/
125137
void Schedule(std::span<Command* const> commands);
@@ -128,6 +140,10 @@ class CommandScheduler final : public wpi::Sendable,
128140
* Schedules multiple commands for execution. Does nothing for commands
129141
* already scheduled.
130142
*
143+
* @warning Using this function directly can often lead to unexpected behavior
144+
* and should be avoided. Instead Triggers should be used to schedule
145+
* Commands.
146+
*
131147
* @param commands the commands to schedule
132148
*/
133149
void Schedule(std::initializer_list<Command*> commands);

0 commit comments

Comments
 (0)