1 #ifndef theplu_yat_utility_scheduler 2 #define theplu_yat_utility_scheduler 25 #include "PriorityQueue.h" 28 #include <boost/exception_ptr.hpp> 29 #include <boost/thread.hpp> 30 #include <boost/shared_ptr.hpp> 95 explicit Job(
unsigned int prio=0);
113 friend class JobHandler;
114 mutable boost::mutex mutex_;
115 void add_prerequisite(
const boost::shared_ptr<Job>&);
118 size_t remove_prerequisite(
const boost::shared_ptr<Job>&);
119 void add_observer(
const boost::shared_ptr<Job>&);
122 std::set<boost::shared_ptr<Job> > prerequisite_;
124 std::vector<boost::shared_ptr<Job> > observers_;
130 enum status { pristine, prepared, running, completed};
134 boost::exception_ptr error_;
154 boost::shared_ptr<Job> prerequisite);
166 size_t jobs(
void)
const;
177 void submit(
const boost::shared_ptr<Job>& job);
185 typedef boost::shared_ptr<Scheduler::Job> JobPtr;
189 bool operator()(
const JobPtr& lhs,
const JobPtr& rhs)
const;
220 explicit Count(
int x=0);
222 void decrement(
void);
226 void increment(
void);
230 mutable boost::mutex mutex_;
234 JobHandlerData(
unsigned int threads);
239 const JobQueue& queue(
void)
const;
240 JobQueue& queue(
void);
242 const Count& job_count(
void)
const;
243 Count& job_count(
void);
245 const Count& running_jobs(
void)
const;
246 Count& running_jobs(
void);
248 const Count& threads(
void)
const;
249 Count& threads(
void);
265 JobHandler(JobHandlerData& data);
269 void process(JobPtr& job);
273 void prepare(JobPtr job);
275 void post_process(JobPtr job);
277 void send2queue(JobPtr& job);
279 JobHandlerData* data_;
287 void post_process(boost::shared_ptr<Job> job);
292 void process(boost::shared_ptr<Job> job);
295 void queue(boost::shared_ptr<Job> job);
298 void throw_if_error(
void)
const;
300 JobHandlerData data_;
301 boost::thread job_handler_;
Handle a number of jobs and send them to threads.
Definition: Scheduler.h:83
void submit(const boost::shared_ptr< Job > &job)
submit a job to Scheduler
Job(unsigned int prio=0)
constructor
The Department of Theoretical Physics namespace as we define it.
virtual void operator()(void)=0
virtual ~Job(void)
destructor
Definition: Scheduler.h:89
thread-safe class around int
Definition: Scheduler.h:216
void interrupt(void)
interrrupt all jobs
void add_dependency(boost::shared_ptr< Job > job, boost::shared_ptr< Job > prerequisite)
add a dependency rule
void wait(void)
wait for all jobs to finish
unsigned int priority(void) const