Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
19 Views

Exposing the Task Scheduler

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.
0 Kudos
2 Replies
Highlighted
19 Views

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);

Study the TBB Refefence manual for more details about the direct use of tasks.
0 Kudos
Highlighted
New Contributor I
19 Views

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
0 Kudos