| 441 | using Config = FastParseExampleConfig; |
| 442 | |
| 443 | void ParallelFor(const std::function<void(size_t)>& f, size_t n, |
| 444 | thread::ThreadPool* thread_pool) { |
| 445 | if (n == 0) return; |
| 446 | if (thread_pool == nullptr) { |
| 447 | for (size_t i = 0; i < n; ++i) { |
| 448 | f(i); |
| 449 | } |
| 450 | } else { |
| 451 | BlockingCounter counter(n - 1); |
| 452 | for (size_t i = 1; i < n; ++i) { |
| 453 | thread_pool->Schedule([i, &f, &counter] { |
| 454 | f(i); |
| 455 | counter.DecrementCount(); |
| 456 | }); |
| 457 | } |
| 458 | f(0); |
| 459 | counter.Wait(); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | enum class Type { Sparse, Dense }; |
| 464 |
no test coverage detected