amino::ws_scheduler< TaskType > Class Template Reference

A work stealing scheduler which store pointers to TaskType. More...

#include <ws_scheduler.h>

List of all members.

Public Member Functions

 ws_scheduler (int threadNum)
virtual ~ws_scheduler ()
void shutdown ()
 put a shutdown signal into the working queues.
void addTask (TaskType *task)
void addTask (int index, TaskType *task)
TaskType * getTask (int threadId)


Detailed Description

template<typename TaskType>
class amino::ws_scheduler< TaskType >

A work stealing scheduler which store pointers to TaskType.

Node: It won't delete any memory space allocated by caller.

Template Parameters:
TaskType type of the tasks to be scheduled

Constructor & Destructor Documentation

template<typename TaskType>
amino::ws_scheduler< TaskType >::ws_scheduler ( int  threadNum  )  [inline]

template<typename TaskType>
virtual amino::ws_scheduler< TaskType >::~ws_scheduler (  )  [inline, virtual]


Member Function Documentation

template<typename TaskType>
void amino::ws_scheduler< TaskType >::shutdown (  )  [inline]

put a shutdown signal into the working queues.

This method puts a NULL pointer into the end of all the internal task queues. So if a work thread get a task pointer with NULL value, it should end the loop.

template<typename TaskType>
void amino::ws_scheduler< TaskType >::addTask ( TaskType *  task  )  [inline]

Add a task into the interal work queues. The task will be added to a rand queue.

Parameters:
task inserting task

template<typename TaskType>
void amino::ws_scheduler< TaskType >::addTask ( int  index,
TaskType *  task 
) [inline]

Add a task into the interal work queues. The task will be added to the queue which specified by function parameter.

Parameters:
index index of the queue which will be used to store the task
task inserting task

template<typename TaskType>
TaskType* amino::ws_scheduler< TaskType >::getTask ( int  threadId  )  [inline]

Get a task from internal queues. The queue with an index of threadId will be checked at first. This method will block if current queue is empty and it fails to steal.

Parameters:
threadId id of requesting thread
Returns:
a task which should be executed. Or NULL as the end signal so executor should NOT call getTask() any more.


The documentation for this class was generated from the following file:

Generated on Tue Dec 9 13:39:40 2008 for Amino by  doxygen 1.5.6