pretty close.
example using vex::task class.
vex::brain Brain;
int myTask() {
int count = 0;
while(1) {
Brain.Screen.printAt( 10, 60, "I am the other task %d", count++ );
// don't hog the cpu :)
vex::task::sleep( 25 );
}
return(0);
}
int main() {
int count = 0;
// this is similar to startTask
vex::task t( myTask );
while(1) {
Brain.Screen.printAt( 10, 30, "Hello from main %d", count++ );
// Allow other tasks to run
vex::task::sleep(10);
}
}
example using vex::thread class
vex::brain Brain;
int myThread() {
int count = 0;
while(1) {
Brain.Screen.printAt( 10, 60, "I am the other task %d", count++ );
// don't hog the cpu :)
vex::this_thread::sleep_for( 25 );
}
return(0);
}
int main() {
int count = 0;
// this is similar to startTask
vex::thread t( myThread );
while(1) {
Brain.Screen.printAt( 10, 30, "Hello from main %d", count++ );
// Allow other tasks to run
vex::this_thread::sleep_for(10);
}
}
So why do we have two different versions of the same thing.
vex::task has methods that will be familiar to ROBOTC users. methods such as setPriority and stop.
vex::thread has methods that will be familiar to users of the C++ standard library. methods such as join.