This seems like a simple question but I'm having a devil of a time getting the details correct.
What I'd like to do is createatask class, lets call it "FooTask"that I can instantiate and task allocate once, then spawn repeatly (as needed). For example:
struct FooTask: public task {Data *_dt;
FooTask() { }
void SetData(Data *data) {
_dt = data;
}
task* execute() {
// do stuff with data
}
};
FooTask *tk1 = 0, *tk2 = 0;void Fooing(Data *data) {
if (tk1 == 0) {
// construct and call task allocate (of some form) on tk1 and tk2
}
if (tl1->state() != task::executing) {
tk1->SetList(data);
tk1->spawn(*tk1); // may not be the correct call/syntax
}
else if (tk2->state() == task::executing) {
tk2->SetList(data);
tk2->spawn(*tk2); // may not be the correct call/syntax
}
else {
// do something else with data
}
}
I've tried various sorts of allocations and recycle_as's but I always end up with some sort of assertion hit. I've pretty much convinced myself that I need to change this to some sort of pipeline or queue, but I'm nowcurious how one would implement this pattern in C++ w/ TBB. Can anyone provide an example or an explaination of my "wrongheadedness"?
Thanks


