ork::MultithreadScheduler Class Reference
[taskgraph]

A Scheduler that can use multiple threads. More...

#include <MultithreadScheduler.h>

Inheritance diagram for ork::MultithreadScheduler:
ork::Scheduler ork::Object

List of all members.

Public Member Functions

 MultithreadScheduler (int prefetchRate=0, int prefetchQueue=0, float frameRate=0.0f, int nThreads=0)
 Creates a new multithread scheduler.
virtual ~MultithreadScheduler ()
 Deletes this scheduler.
virtual bool supportsPrefetch (bool gpuTasks)
 Returns true if the prefetch rate or the fixed frame rate is not null, or if there are several threads and gpuTasks is false.
virtual void schedule (ptr< Task > task)
 Adds a task whose deadline is not immediate.
virtual void reschedule (ptr< Task > task, Task::reason r, unsigned int deadline)
 Forces the reexecution of the given task and of its sub tasks.
virtual void run (ptr< Task > task)
 Executes the given tasks.
void monitorTask (const string &taskType)
 Adds the given task type to the tasks whose execution times must be monitored (debug).

Protected Member Functions

void init (int prefetchRate, int prefetchQueue, float frameRate, int nThreads)
 Initializes this scheduler.

Detailed Description

A Scheduler that can use multiple threads.

This scheduler can work with one or more threads, and it can try to follow a fixed framerate (i.e. a number of calls to run per second). If a prefetch rate is specified, the main thread executes at least the specified number of prefetching tasks par frame (when such tasks are available), after all the tasks for the current frame have been executed. Hence if a prefetch rate is specified, or if a fixed frame rate is specified, this scheduler supports prefetching of tasks of any kind. Otherwise, if several threads are used, prefetching of cpu tasks is supported, but not prefetching of gpu tasks.


Constructor & Destructor Documentation

ork::MultithreadScheduler::MultithreadScheduler ( int  prefetchRate = 0,
int  prefetchQueue = 0,
float  frameRate = 0.0f,
int  nThreads = 0 
)

Creates a new multithread scheduler.

Parameters:
prefetchRate the minimum number of prefetch task to execute at each frame, after all the tasks for the current frame have been executed (and if prefetching tasks are available). The prefetching of gpu tasks is only possible if this rate is not 0.
prefetchQueue the maximum number of prefetching tasks that can be queued for execution. If a prefetch rate or a fixed frame rate is specified, this value must not be 0. When the queue is full, new prefetch tasks are simply discarded and schedule returns false. This maximum queue size prevents the number of prefetching tasks to grow unbounded, if new prefetching tasks are generated at a greater rate than the rate at which they are executed.
frameRate a fixed framerate that this scheduler should try to follow, or 0 to not fix any framerate.
nThreads the number of threads to use in addition to the main thread of the application. Hence 0 means that only one thread will be used, the main application thread.
virtual ork::MultithreadScheduler::~MultithreadScheduler (  )  [virtual]

Deletes this scheduler.


Member Function Documentation

void ork::MultithreadScheduler::init ( int  prefetchRate,
int  prefetchQueue,
float  frameRate,
int  nThreads 
) [protected]

Initializes this scheduler.

See MultithreadScheduler.

void ork::MultithreadScheduler::monitorTask ( const string &  taskType  ) 

Adds the given task type to the tasks whose execution times must be monitored (debug).

virtual void ork::MultithreadScheduler::reschedule ( ptr< Task task,
Task::reason  r,
unsigned int  deadline 
) [virtual]

Forces the reexecution of the given task and of its sub tasks.

Parameters:
task a task or task graph that must be reexecuted. This task is marked as undone (with Task::setIsDone) so that it will be reexecuted.
r the reason why the task must be reexecuted.
deadline the frame number before which this task must be reexecuted.

Implements ork::Scheduler.

virtual void ork::MultithreadScheduler::run ( ptr< Task task  )  [virtual]

Executes the given tasks.

This method does not return before all tasks with an immediate deadline are completed.

Parameters:
task a task or task graph to be executed.

Implements ork::Scheduler.

virtual void ork::MultithreadScheduler::schedule ( ptr< Task task  )  [virtual]

Adds a task whose deadline is not immediate.

This method must not be called if this scheduler does not support prefetch (see supportsPrefetch). Otherwise it adds this task and its sub tasks to the list of tasks to be executed by this scheduler, and returns immediately (i.e. before these tasks are executed).

Parameters:
task a task or task graph whose deadline is not immediate.

Implements ork::Scheduler.

virtual bool ork::MultithreadScheduler::supportsPrefetch ( bool  gpuTasks  )  [virtual]

Returns true if the prefetch rate or the fixed frame rate is not null, or if there are several threads and gpuTasks is false.

In addition, if there is only one thread for cpu tasks, and for gpu tasks in all cases, the curent number of prefetching tasks waiting for execution must be less than the prefetch queue size, otherwise this method returns false.

Implements ork::Scheduler.


Generated on Mon Oct 18 09:36:12 2010 for ork by  doxygen 1.6.1