Go to Post Karthik is afraid of the day he can't agasabapathy. - DesignComp [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-02-2013, 22:28
JCrusoe JCrusoe is offline
Jacque Crusoe
FRC #3880 (Tiki Techs)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Hawaii
Posts: 5
JCrusoe is an unknown quantity at this point
Multitasking

After a good hour or so of reading through documentations and any other related page I could find, creating new tasks has me stumped. I'm not sure exactly where to put the line of code the documentation shows as an example, or where to point the function to (do I just leave it as FUNCPTR?).
Code:
Task myTask("taskname", (FUNCPTR) functionToStart)
Basically I'm extremely confused haha. I've tried many off the wall things like creating a new object that is a task, and then modifying that line to put in the initialisation. If someone could point me in the right direction I would be eternally grateful =)

Jacque
Reply With Quote
  #2   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
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi