comparison Core/JobsEngine/JobsRegistry.cpp @ 2976:cb5d75143da0

Asynchronous generation of ZIP archives and DICOM medias
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Dec 2018 12:23:46 +0100
parents d924f9bb61cc
children 4e43e67f8ecf
comparison
equal deleted inserted replaced
2970:eea66afed0db 2976:cb5d75143da0
261 { 261 {
262 // WARNING: Cannot directly access the "job_" member, as long 262 // WARNING: Cannot directly access the "job_" member, as long
263 // as a "RunningJob" instance is running. We do not use a 263 // as a "RunningJob" instance is running. We do not use a
264 // mutex at the "JobHandler" level, as serialization would be 264 // mutex at the "JobHandler" level, as serialization would be
265 // blocked while a step in the job is running. Instead, we 265 // blocked while a step in the job is running. Instead, we
266 // save a snapshot of the serialized job. 266 // save a snapshot of the serialized job. (*)
267 267
268 if (lastStatus_.HasSerialized()) 268 if (lastStatus_.HasSerialized())
269 { 269 {
270 target[JOB] = lastStatus_.GetSerialized(); 270 target[JOB] = lastStatus_.GetSerialized();
271 ok = true; 271 ok = true;
625 handler.GetLastStatus(), 625 handler.GetLastStatus(),
626 handler.GetCreationTime(), 626 handler.GetCreationTime(),
627 handler.GetLastStateChangeTime(), 627 handler.GetLastStateChangeTime(),
628 handler.GetRuntime()); 628 handler.GetRuntime());
629 return true; 629 return true;
630 }
631 }
632
633
634 bool JobsRegistry::GetJobOutput(std::string& output,
635 MimeType& mime,
636 const std::string& job,
637 const std::string& key)
638 {
639 boost::mutex::scoped_lock lock(mutex_);
640 CheckInvariants();
641
642 JobsIndex::const_iterator found = jobsIndex_.find(job);
643
644 if (found == jobsIndex_.end())
645 {
646 return false;
647 }
648 else
649 {
650 const JobHandler& handler = *found->second;
651
652 if (handler.GetState() == JobState_Success)
653 {
654 return handler.GetJob().GetOutput(output, mime, key);
655 }
656 else
657 {
658 return false;
659 }
630 } 660 }
631 } 661 }
632 662
633 663
634 void JobsRegistry::SubmitInternal(std::string& id, 664 void JobsRegistry::SubmitInternal(std::string& id,