MCPcopy Create free account
hub / github.com/Gecode/gecode / returnWork

Method returnWork

contribs/qecode/WorkManager.cc:146–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void WorkManager::returnWork(AQWorker* worker,Strategy ret,list<QWork> todo,vector<int> position) {
147 // If the worker is not among the actives ones, ignore his job. Else, withdraw it from the active workers
148 // and process its result
149
150 // clock_t start = clock();
151 // cout<<worker<<" WAIT returnWork "<<start<<endl;
152 mex.acquire();
153 // clock_t stop = clock();
154 // cout<<worker<<" CONT returnWork "<<stop<<" waited "<<(stop-start)<<endl;
155 // cout<<"RW returnWork acquired"<<endl;
156 // cout<<"returning work at ";
157 // if (position.empty()) cout<<"empty";
158 // for (int i=0;i< position.size();i++) cout<<position[i]<<" ";
159 // cout<<endl;
160
161 bool ok=false;
162 list<AQWorker*>::iterator i = actives.begin();
163 while (!(i == actives.end()) && !ok) {
164 bool avance=true;
165 if ((*i) == worker) {
166 // cout<<"RW Worker found in actives. Deleting"<<endl;
167 i=actives.erase(i);
168 avance = false;
169 ok=true;
170 }
171 if (avance) ++i;
172 }
173 if (!ok) {
174 // cout<<"RW Ignoring work"<<endl;
175 // when ignoring the result, we have to delete every search engine from the eventual to-do works it did
176 for (list<QWork>::iterator j = todo.begin();j != todo.end();j++) {
177 (*j).clean();
178 }
179 // cout<<"RW release"<<endl;
180 mex.release();
181 return;
182 }
183
184 // processing results...
185
186 // adding todo to Todos
187
188 // going to father of substrategy
189 bool acceptable = true;
190 Strategy father = S.getSubStrategy(position);
191 if (father.isDummy() && (father.id() != S.id())) {
192 // cout<<"ERROR : RW Work was not in current strategy. Ignoring."<<endl;
193 acceptable=false;
194 }
195 // remove the Todo node that marked this work
196 if (acceptable) {
197 // cout<<" RW Father position is ";
198 // vector<int> checkPosition = father.getPosition();
199 // if (checkPosition.empty()) cout<<"empty";
200 // for (int i=0;i< checkPosition.size();i++) cout<<checkPosition[i]<<" ";
201 // cout<<endl;
202
203 for (list<QWork>::iterator j = todo.begin();j != todo.end();j++) {

Callers 1

runMethod · 0.80

Calls 15

getSubStrategyMethod · 0.80
wakeMethod · 0.80
detachMethod · 0.80
attachMethod · 0.80
qt_of_varMethod · 0.80
acquireMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
releaseMethod · 0.45
idMethod · 0.45
emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected