MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / runSync

Method runSync

src/common/Task.cpp:215–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void Coordinator::runSync(Task* task)
216{
217 int cntWorkers = setupWorkers(task->getMaxWorkers());
218 if (cntWorkers < 1)
219 return;
220
221 HalfStaticArray<WorkerAndThd, 8> taskWorkers(*m_pool, cntWorkers);
222
223 Worker* syncWorker = getWorker();
224 taskWorkers.push(WorkerAndThd(syncWorker, NULL));
225
226 for (int i = 1; i < cntWorkers; i++)
227 {
228 WorkerThread* thd = getThread();
229 if (thd)
230 {
231 Worker* w = getWorker();
232 taskWorkers.push(WorkerAndThd(w, thd));
233
234 w->setTask(task);
235 thd->runWorker(w);
236 }
237 }
238
239 // run syncronously
240 syncWorker->setTask(task);
241 syncWorker->work(NULL);
242
243 // wait for all workes
244 for (int i = 0; i < cntWorkers; i++)
245 {
246 WorkerAndThd& wt = taskWorkers[i];
247 if (wt.thread)
248 {
249 if (!wt.worker->isIdle())
250 wt.thread->waitForState(WorkerThread::IDLE, -1);
251
252 releaseThread(wt.thread);
253 }
254 releaseWorker(wt.worker);
255 }
256}
257
258Worker* Coordinator::getWorker()
259{

Callers 2

VIO_sweepFunction · 0.80
IDX_create_indexFunction · 0.80

Calls 8

WorkerAndThdClass · 0.85
setTaskMethod · 0.80
runWorkerMethod · 0.80
workMethod · 0.80
isIdleMethod · 0.80
waitForStateMethod · 0.80
getMaxWorkersMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected