In PROS V5 (3.8.0) tutorial “Delaying the start of a task”,
https://pros.cs.purdue.edu/v5/tutorials/topical/notifications.html
the example shows:
void opcontrol() {
pros::Task delayed_start_task{ [] {
// block this task until signalled to begin
while (pros::Task::notify_take(true, TIMEOUT_MAX)) ; //<===== this line
while (true) {
do_task_thing();
do_another_task_thing();
pros::delay(20);
}
} };
pros::Controller master{ pros::E_CONTROLLER_MASTER };
pros::Motor left_motor{ LEFT_MOTOR_PORT };
pros::Motor right_motor{ RIGHT_MOTOR_PORT };
while (true) {
// start the task when the A button is pressed
if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_A)) {
delayed_start_task.notify();
}
...
}
}
But, shouldn’t we use
while (!pros::Task::notify_take(true, TIMEOUT_MAX)) ;
for the blocking instead?
My understanding is when there is no any notification received, the notify_take() will return 0, thus the while loop can continue.
Your comments are appreciated.