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

Method getWork

contribs/qecode/WorkManager.cc:107–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107QWork WorkManager::getWork(AQWorker* worker) {
108 // clock_t start = clock();
109 // cout<<worker<<" WAIT getWork "<<start<<endl;
110 mex.acquire();
111 // clock_t stop = clock();
112 // cout<<worker<<" CONT getWork "<<stop<<" waited "<<(stop-start)<<endl;
113
114 // cout<<"G ";cout.flush();
115 // cout<<"WM getwork acquired"<<endl;
116 QWork ret;
117 if (Todos.empty()) {
118 // cout<<"WM : Todos was empty"<<endl;
119 if (actives.empty()) {
120 // cout<<"WM : Actives was empty, stopping worker."<<endl;
121 ret = QWork::Stop();
122 finished=true;
123 }
124 else {
125 getNewWorks();
126 // cout<<"WM sleeping worker"<<endl;
127 ret = QWork::Wait();
128 idles.push_back(worker);
129 }
130 }
131 else {
132 // cout<<"WM : giving work ";
133 ret = Todos.top();
134 Todos.pop();
135 // if (ret.root().empty()) cout<<"empty";
136 // for (int i=0;i< ret.root().size();i++) cout<<ret.root()[i]<<" ";
137 // cout<<endl;
138
139 actives.push_back(worker);
140 }
141 // cout<<"WM getwork release"<<endl;
142 mex.release();
143 return ret;
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

Callers 1

runMethod · 0.80

Calls 6

StopClass · 0.85
WaitClass · 0.85
acquireMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected