yat
0.14.5pre
|
Handle a number of jobs and send them to threads. More...
#include <yat/utility/Scheduler.h>
Classes | |
class | Job |
Public Member Functions | |
Scheduler (unsigned int threads) | |
constructor More... | |
void | add_dependency (boost::shared_ptr< Job > job, boost::shared_ptr< Job > prerequisite) |
add a dependency rule More... | |
void | interrupt (void) |
interrrupt all jobs | |
void | submit (boost::shared_ptr< Job > job) |
submit a job to Scheduler More... | |
void | wait (void) |
wait for all jobs to finish | |
Handle a number of jobs and send them to threads.
Scheduler starts a (user defined) number of threads and handles a series of Jobs. The Jobs can have dependencies, such that Job X must finish before Job Y can run, and the Scheduler takes care of these dependencies. Here is a small code example in which two threads are used to process the four jobs, MyJob
. The jobs have a dependency that job4 can not run until the three first jobs have completed.
The Scheduler sends jobs to the workers taking into account dependencies, priorities and the order in which the Scheduler has seen the Jobs. Of the Jobs that are ready to run, i.e., all jobs it depends on have completed, the Scheduler chose the Job with highest priority. If two Jobs have the same priority, the Scheduler sends them in the order of appearance, i.e., if the Scheduler saw Job X before Job Y, Job X is run before Job X.
theplu::yat::utility::Scheduler::Scheduler | ( | unsigned int | threads | ) |
constructor
threads | number of threads that are used |
void theplu::yat::utility::Scheduler::submit | ( | boost::shared_ptr< Job > | job | ) |
submit a job to Scheduler
If job depends on other jobs, they are also submitted to the Scheduler.