void ServerScheduler::GetListOfJobs(ListOfStrings& jobs) { boost::mutex::scoped_lock lock(mutex_); jobs.clear(); for (Jobs::const_iterator it = jobs_.begin(); it != jobs_.end(); ++it) { jobs.push_back(it->first); } }
bool ServerScheduler::SubmitAndWait(ListOfStrings& outputs, ServerJob& job) { std::string jobId = job.GetId(); outputs.clear(); if (job.filters_.empty()) { return true; } // Add a sink filter to collect all the results of the filters // that have no next filter. ServerCommandInstance& sink = job.AddCommand(new Sink(outputs)); for (std::list<ServerCommandInstance*>::iterator it = job.filters_.begin(); it != job.filters_.end(); ++it) { if ((*it) != &sink && (*it)->IsConnectedToSink()) { (*it)->ConnectOutput(sink); } } // Submit the job SubmitInternal(job, true); // Wait for the job to complete (either success or failure) JobStatus status; { boost::mutex::scoped_lock lock(mutex_); assert(watchedJobStatus_.find(jobId) != watchedJobStatus_.end()); while (watchedJobStatus_[jobId] == JobStatus_Running) { watchedJobFinished_.wait(lock); } status = watchedJobStatus_[jobId]; watchedJobStatus_.erase(jobId); } return (status == JobStatus_Success); }