Changeset 3349
- Timestamp:
- Nov 13, 2014, 4:59:26 AM (9 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/Scheduler.cc
r3348 r3349 31 31 32 32 Scheduler::Scheduler(unsigned int threads) 33 : running_jobs_(0) 33 34 { 34 35 assert(threads); … … 40 41 void Scheduler::post_process(JobPtr job) 41 42 { 42 running_jobs_.erase(job); 43 --running_jobs_; 44 assert(running_jobs_>=0); 43 45 job->status_ = Job::completed; 44 46 // check if there are jobs waiting for job … … 90 92 { 91 93 job->status_ = Job::running; 92 running_jobs_.insert(job); 94 ++running_jobs_; 95 assert(running_jobs_>0); 93 96 queue_.push(job); 94 97 } … … 97 100 void Scheduler::submit(JobPtr job) 98 101 { 102 // If any job has been completed since last submission, 103 // post-process the completed job 104 JobPtr completed_job; 105 while (completed_.try_pop(completed_job)) 106 post_process(completed_job); 99 107 process(job); 100 108 } … … 103 111 void Scheduler::wait(void) 104 112 { 105 while (running_jobs_ .size()|| completed_.size()) {113 while (running_jobs_ || completed_.size()) { 106 114 JobPtr job; 107 115 completed_.pop(job); -
trunk/yat/utility/Scheduler.h
r3348 r3349 108 108 /** 109 109 \brief submit a \a job to Scheduler 110 111 If \a job depends on other jobs, they are also submitted to the 112 Scheduler. 110 113 */ 111 114 void submit(boost::shared_ptr<Job> job); … … 149 152 150 153 typedef boost::shared_ptr<Scheduler::Job> JobPtr; 151 std::set<JobPtr>running_jobs_;154 int running_jobs_; 152 155 153 156 // value lists all jobs that depend on key, i.e., key has to
Note: See TracChangeset
for help on using the changeset viewer.