đTasks
Multithreading made simple
Tasks allow the code to execute multiple functions simultaneously. For example, one task could handle the driving inputs, and another task could spin a catapult or flywheel at the same time.
Tasks themselves are functions that return an integer (it's C++, go along with it). You can put whatever code you want inside of it, but usually there's a while loop so actions within the task execute more than once. Here's a basic task (called myTask
) that spins a flywheel forward:
Tasks can be created with this line of code, and will not run until they have been created. The variable spinFlywheel
stores the task internally for future reference.
If you want the task to stop running, call the stop()
function on it:
We recommend using tasks for controlling lifts, catapults, or flywheels when the control algorithm required is non-trivial.
Last updated
Was this helpful?