| 226 | } |
| 227 | |
| 228 | void task_worker::loop() |
| 229 | { |
| 230 | task_queue *q = queue(); |
| 231 | int best_batch_size = pool_spec().dequeue_batch_size; |
| 232 | |
| 233 | while (_is_running) { |
| 234 | int batch_size = best_batch_size; |
| 235 | task *task = q->dequeue(batch_size), *next; |
| 236 | |
| 237 | q->decrease_count(batch_size); |
| 238 | |
| 239 | #ifndef NDEBUG |
| 240 | int count = 0; |
| 241 | #endif |
| 242 | while (task != nullptr) { |
| 243 | next = task->next; |
| 244 | task->next = nullptr; |
| 245 | task->exec_internal(); |
| 246 | task = next; |
| 247 | #ifndef NDEBUG |
| 248 | count++; |
| 249 | #endif |
| 250 | } |
| 251 | |
| 252 | #ifndef NDEBUG |
| 253 | CHECK_EQ_MSG(count, batch_size, "returned task count and batch size do not match"); |
| 254 | #endif |
| 255 | |
| 256 | _processed_task_count += batch_size; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | const threadpool_spec &task_worker::pool_spec() const { return pool()->spec(); } |
| 261 |
nothing calls this directly
no test coverage detected