Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

Question regarding re-executing TBB tasks


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Zipster   Crossbones+   -  Reputation: 402

Like
0Likes
Like

Posted 26 October 2012 - 07:11 PM

I haven't been able to find much information on the net pertaining to a particular usage pattern of TBB tasks, wherein the task recycles itself so it can be executed again, in my case for some extended period of time:
class MyTask : public tbb::task
{
public:
	 virtual tbb::task* execute()
	 {
		  // ... do work ...
		  if (!isDone())
		  {
			   recycle_as_safe_continuation();
			   set_ref_count(1);

			   // Task starvation?
			   // return this;
		  }

		  return 0;
	 }

private:
	 bool isDone() const { ... }
}
My question is regarding the behavior or returning 0 versus this after recycling the task. The scheduling documentation states that returning a task bypasses the scheduler, and the thread will execute the returned task next. If all the active worker threads are executing such self re-executing tasks, and they all return themselves as the next task, does this mean that the scheduler will starve any/all other tasks in the ready pool(s) for as long as the active tasks aren't done? Alternatively, if I return 0 instead, are other threads free to steal the task, or does the non-zero refcount prevent that?

Sponsor:

#2 Alpha_ProgDes   Crossbones+   -  Reputation: 3416

Like
0Likes
Like

Posted 26 October 2012 - 08:32 PM

I have absolutely no answer to your question. But I wanted to say, Welcome back! Long time no see. :)

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS