#include <UT_ThreadedAlgorithm.h>
Public Member Functions | |
| UT_JobInfo (int jobidx, int numjobs, UT_Lock *lock, SYS_AtomicInt32 *aint=0) | |
| int | job () const |
| int | numJobs () const |
| int32 | nextTask () const |
| void | resetTasks () const |
| void | divideWork (int units, int &start, int &end) const |
| void | lock () const |
| void | unlock () const |
Protected Attributes | |
| int | myJob |
| int | myNumJobs |
| UT_Lock * | myLock |
| SYS_AtomicInt32 * | myTask |
| int | myLocalTask |
Definition at line 94 of file UT_ThreadedAlgorithm.h.
| UT_JobInfo::UT_JobInfo | ( | int | jobidx, | |
| int | numjobs, | |||
| UT_Lock * | lock, | |||
| SYS_AtomicInt32 * | aint = 0 | |||
| ) | [inline] |
Definition at line 97 of file UT_ThreadedAlgorithm.h.
| void UT_JobInfo::divideWork | ( | int | units, | |
| int & | start, | |||
| int & | end | |||
| ) | const |
Given "units" work, report which units you are responsible for with this JobInfo. The resulting interval is [start, end), Appropriate for loop: for (info.divideWork(total, i, end); i < end; i++)
| int UT_JobInfo::job | ( | ) | const [inline] |
The number of jobs is the total number of threads that is running and job() is your thread #, starting at 0 and going up to numJobs()-1
Definition at line 109 of file UT_ThreadedAlgorithm.h.
| void UT_JobInfo::lock | ( | ) | const [inline] |
lock and unlock a lock shared by all the jobs. This lock is special cased to a no-op in the threadless case to avoid overhead.
Definition at line 137 of file UT_ThreadedAlgorithm.h.
| int32 UT_JobInfo::nextTask | ( | ) | const |
These control a shared AtomicInt32 so you can split tasks among jobs using load balancing. The total number is in this case up to you to detect. The JobIds will start with 0 and each call will get a unique higher number. Example: for (i = info.nextTask(); i < maxtask; i = info.nextTask())
| int UT_JobInfo::numJobs | ( | ) | const [inline] |
| void UT_JobInfo::resetTasks | ( | ) | const |
Resets the task list. You are responsible for creating a barrier to ensure that all the other threads have hit the end of the tasks! This is *not* required for your first loop as you will already start at task 0.
| void UT_JobInfo::unlock | ( | ) | const [inline] |
Definition at line 142 of file UT_ThreadedAlgorithm.h.
int UT_JobInfo::myJob [protected] |
Definition at line 149 of file UT_ThreadedAlgorithm.h.
int UT_JobInfo::myLocalTask [mutable, protected] |
Definition at line 152 of file UT_ThreadedAlgorithm.h.
UT_Lock* UT_JobInfo::myLock [protected] |
Definition at line 150 of file UT_ThreadedAlgorithm.h.
int UT_JobInfo::myNumJobs [protected] |
Definition at line 149 of file UT_ThreadedAlgorithm.h.
SYS_AtomicInt32* UT_JobInfo::myTask [protected] |
Definition at line 151 of file UT_ThreadedAlgorithm.h.
1.5.9