- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been evaluating the use of TBB for quite some time and i have a question about the use
of Task sheduler. As I understand TBB aims at hiding the complexity of threading and task scheduling
from the user completely.So I assume that this is the reason why the Task scheduler is not exposed
extensively to the user.
By exposing the task scheduler, I mean to be possible to define tasks ( by classes deriving from tbb::task
and overriding execute method) and be able to queue these tasks to the scheduler for execution.
For example,
// Defining a Task required of user
TaskA : tbb::task{
void execute(){
// Some Algorithm
}
};
TaskA taskA;
task_scheduler scheduler;
scheduler.QueueTask( taskA);
Can thepresent TBB scheduler be used in this way or is it possible that the scheduler be tweaked to be used
this way too? I would be interested to know the implications of this.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes TBB can be used this way right now, though the syntax to do that is somewhat different. One example how it can be done is:
TaskA& taskA = *new (allocate_root()) TaskA;
spawn_root_and_wait(taskA);TaskA& taskA = *new (allocate_root()) TaskA;
Study the TBB Refefence manual for more details about the direct use of tasks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Shankar
I have been evaluating the use of TBB for quite some time and i have a question about the use
of Task sheduler. As I understand TBB aims at hiding the complexity of threading and task scheduling
from the user completely.So I assume that this is the reason why the Task scheduler is not exposed
extensively to the user.
By exposing the task scheduler, I mean to be possible to define tasks ( by classes deriving from tbb::task
and overriding execute method) and be able to queue these tasks to the scheduler for execution.
For example,
// Defining a Task required of user
TaskA : tbb::task{
void execute(){
// Some Algorithm
}
};
TaskA taskA;
task_scheduler scheduler;
scheduler.QueueTask( taskA);
Can thepresent TBB scheduler be used in this way or is it possible that the scheduler be tweaked to be used
this way too? I would be interested to know the implications of this.
Why would you want to do this now?
Technically, you can override the scheduler by returning the next task to execute from the call to execute(). So you can do the queue you want just by creating a task that will return the next task from a queue after it's executed itself.
AJ
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page