comparison 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
comparison
equal deleted inserted replaced
2623:bd6e0b70e915 2624:714dcddeb65f
152 } 152 }
153 153
154 154
155 LuaJobManager::Lock::~Lock() 155 LuaJobManager::Lock::~Lock()
156 { 156 {
157 assert(jobLock_.get() != NULL); 157 bool isEmpty;
158
159 assert(jobLock_.get() != NULL);
160 isEmpty = (isNewJob_ &&
161 jobLock_->GetOperationsCount() == 0);
162
158 jobLock_.reset(NULL); 163 jobLock_.reset(NULL);
159 164
160 if (isNewJob_) 165 if (isNewJob_)
161 { 166 {
162 engine_.GetRegistry().Submit(that_.currentId_, that_.currentJob_, that_.priority_); 167 if (isEmpty)
168 {
169 // No operation was added, discard the newly created job
170 isNewJob_ = false;
171 delete that_.currentJob_;
172 that_.currentJob_ = NULL;
173 }
174 else
175 {
176 engine_.GetRegistry().Submit(that_.currentId_, that_.currentJob_, that_.priority_);
177 }
163 } 178 }
164 } 179 }
165 180
166 181
167 size_t LuaJobManager::Lock::AddDeleteResourceOperation(ServerContext& context) 182 size_t LuaJobManager::Lock::AddDeleteResourceOperation(ServerContext& context)