Thread: Multitasking
View Single Post
  #1   Spotlight this post!  
Unread 12-02-2013, 01:23
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: Multitasking

The most common way of implementing a new task is using a static void in an object's class. The compressor class uses a task to monitor the air flow, etc. If you want to write a task, you can take a look at the .cpp of the compressor class. Here is some sample code too.

This is a sample header file.
Code:
class Sample {
public:
//constructor, other functions
private:
Task task;
static void TaskRunner(Sample *s);
};
And here is the corresponding .cpp
Code:
Sample::Sample() :
task("Sample Task", (FUNCPTR) TaskRunner)
{
task.Start((INT32)this);
}

void Sample::TaskRunner(Sample *s) {
//Task code here
}
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs
Reply With Quote