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

Method run

contribs/qecode/Worker.cc:83–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void QWorker::run() {
84
85 while(true) {
86 access.acquire();
87 stopandforget=0;
88 finished=false;
89 todo.clear();
90 access.release();
91 // cout<<"QWorker "<<this<<" : One turn !"<<endl;
92 QWork cur= wm->getWork(this);
93 // cout<<"QWorker "<<this<<" got work"<<endl;
94 if (cur.isStop()) {
95 return;
96 }
97 else if (cur.isWait()) {
98 // clock_t start = clock();
99 // cout<<this<<" WAIT goToWork "<<start<<endl;
100 goToWork.wait();
101 // clock_t stop = clock();
102 // cout<<this<<" CONT goToWork "<<stop<<" waited "<<(stop-start)<<endl;
103 }
104 else {
105 access.acquire();
106 currentWork = cur;
107 access.release();
108 Strategy ret=solve();
109 access.acquire();
110 bool forget= (stopandforget == 2);
111 access.release();
112 if (!forget) {
113 // cout<<"QWorker "<<this<<" returning work..."<<ret.nbTodos()<<" todo in strategy and "<<todo.size()<<" works to do."<<endl;
114 wm->returnWork(this,ret,todo,cur.root());
115 }
116 else {
117 // cout<<"QWorker "<<this<<" forgetting work..."<<endl;
118
119 for(list<QWork>::iterator i(todo.begin());i != todo.end();i++) {
120 (*i).clean();
121 }
122 todo.clear();
123 }
124 }
125 }
126}
127
128Strategy QWorker::solve() {
129 return rsolve(currentWork.getScope(),currentWork.getRemaining());

Callers

nothing calls this directly

Calls 9

solveFunction · 0.85
getWorkMethod · 0.80
returnWorkMethod · 0.80
acquireMethod · 0.45
clearMethod · 0.45
releaseMethod · 0.45
waitMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected