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

Method next

gecode/search/par/pbs.hpp:209–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208 template<class Collect>
209 Space*
210 PBS<Collect>::next(void) {
211 m.acquire();
212 if (solutions.empty()) {
213 // Clear all
214 tostop = false;
215 slave_stop = false;
216
217 // Invariant: all slaves are idle!
218 assert(n_busy == 0);
219 assert(!tostop);
220
221 if (n_active > 0) {
222 // Run all active slaves
223 n_busy = n_active;
224 for (unsigned int i=0U; i<n_active; i++)
225 Support::Thread::run(slaves[i]);
226 m.release();
227 // Wait for all slaves to become idle
228 idle.wait();
229 m.acquire();
230 }
231 }
232
233 // Invariant all slaves are idle!
234 assert(n_busy == 0);
235
236 Space* s;
237
238 // Process solutions
239 if (solutions.empty()) {
240 s = nullptr;
241 } else {
242 Slave<Collect>* r;
243 s = solutions.get(r);
244 if (Collect::best)
245 for (unsigned int i=0U; i<n_active; i++)
246 if (slaves[i] != r)
247 slaves[i]->constrain(*s);
248 }
249
250 m.release();
251 return s;
252 }
253
254 template<class Collect>
255 bool

Callers 3

runMethod · 0.45
runMethod · 0.45
runMethod · 0.45

Calls 6

acquireMethod · 0.45
emptyMethod · 0.45
releaseMethod · 0.45
waitMethod · 0.45
getMethod · 0.45
constrainMethod · 0.45

Tested by

no test coverage detected