Mercurial > hg > orthanc
diff OrthancServer/ServerJobs/LuaJobManager.cpp @ 2624:714dcddeb65f jobs
asynchronous c-movoe
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 May 2018 21:44:22 +0200 |
parents | 1232922c8793 |
children | 3ce8863398ab |
line wrap: on
line diff
--- a/OrthancServer/ServerJobs/LuaJobManager.cpp Wed May 23 14:28:25 2018 +0200 +++ b/OrthancServer/ServerJobs/LuaJobManager.cpp Thu May 24 21:44:22 2018 +0200 @@ -154,12 +154,27 @@ LuaJobManager::Lock::~Lock() { + bool isEmpty; + assert(jobLock_.get() != NULL); + isEmpty = (isNewJob_ && + jobLock_->GetOperationsCount() == 0); + jobLock_.reset(NULL); if (isNewJob_) { - engine_.GetRegistry().Submit(that_.currentId_, that_.currentJob_, that_.priority_); + if (isEmpty) + { + // No operation was added, discard the newly created job + isNewJob_ = false; + delete that_.currentJob_; + that_.currentJob_ = NULL; + } + else + { + engine_.GetRegistry().Submit(that_.currentId_, that_.currentJob_, that_.priority_); + } } }