execute worker thread
| 4419 | |
| 4420 | // execute worker thread |
| 4421 | void GrepWorker::execute() |
| 4422 | { |
| 4423 | if (Static::cores >= 3) |
| 4424 | set_this_thread_affinity_and_priority(id); |
| 4425 | |
| 4426 | Job job; |
| 4427 | |
| 4428 | while (!out.eof && !out.cancelled()) |
| 4429 | { |
| 4430 | // wait for next job |
| 4431 | next_job(job); |
| 4432 | |
| 4433 | // worker should stop? |
| 4434 | if (job.none()) |
| 4435 | break; |
| 4436 | |
| 4437 | // start synchronizing output for this job slot in ORDERED mode (--sort) |
| 4438 | out.begin(job.slot); |
| 4439 | |
| 4440 | // search the file for this job, an empty pathname means stdin |
| 4441 | search(job.pathname.empty() ? Static::LABEL_STANDARD_INPUT : job.pathname.c_str(), job.cost); |
| 4442 | |
| 4443 | // end output in ORDERED mode (--sort) for this job slot |
| 4444 | out.end(); |
| 4445 | |
| 4446 | #ifndef WITH_LOCK_FREE_JOB_QUEUE |
| 4447 | // if only one job is left to do or nothing to do, then try stealing another job from a co-worker |
| 4448 | if (jobs.todo <= 1) |
| 4449 | master->steal(this); |
| 4450 | #endif |
| 4451 | } |
| 4452 | } |
| 4453 | |
| 4454 | // the CNF of Boolean search queries and patterns |
| 4455 | CNF Static::bcnf; |