Changeset 3828 for trunk/yat/utility/Scheduler.cc
- Timestamp:
- Jul 23, 2019, 5:05:09 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/Scheduler.cc
r3826 r3828 53 53 void Scheduler::interrupt(void) 54 54 { 55 throw_if_error(); 56 if (!job_handler_.joinable()) 57 return; 58 55 59 // first signal to JobHandler that Scheduler is waiting 56 60 boost::shared_ptr<Job> end; … … 72 76 { 73 77 throw_if_error(); 78 // if JobHandler is not joinable implies it is not executing, 79 // launch a new thread executing a JobHandler. 80 if (!job_handler_.joinable()) { 81 assert(data_.jobs().empty()); 82 /* 83 We cannot relaunch a thread, so instead we create a new thread 84 and move its guts to our member variable, job_handler_. 85 In c++11 we could do: 86 job_handler_ = boost::thread(JobHandler(data_)); 87 but in c++98 we instead use swap 88 */ 89 JobHandler tmp_handler(data_); 90 boost::thread tmp(tmp_handler); 91 swap(tmp, job_handler_); 92 } 74 93 data_.jobs().push(job); 75 94 } … … 99 118 void Scheduler::wait(void) 100 119 { 120 throw_if_error(); 121 if (!job_handler_.joinable()) 122 return; 123 101 124 // first signal to JobHandler that Scheduler is waiting 102 125 boost::shared_ptr<Job> end;
Note: See TracChangeset
for help on using the changeset viewer.