| 392 | |
| 393 | |
| 394 | point_count_t EsriReader::read(PointViewPtr view, point_count_t count) |
| 395 | { |
| 396 | point_count_t numRead = 0; |
| 397 | |
| 398 | if (m_tilesToProcess == 0) |
| 399 | return 0; |
| 400 | |
| 401 | do |
| 402 | { |
| 403 | std::unique_lock<std::mutex> l(m_mutex); |
| 404 | if (m_contents.size()) |
| 405 | { |
| 406 | TileContents tile = std::move(m_contents.front()); |
| 407 | m_contents.pop(); |
| 408 | l.unlock(); |
| 409 | checkTile(tile); |
| 410 | process(view, tile, count - numRead); |
| 411 | numRead += tile.size(); |
| 412 | m_tilesToProcess--; |
| 413 | } |
| 414 | else |
| 415 | m_contentsCv.wait(l); |
| 416 | } while (m_tilesToProcess && numRead < count); |
| 417 | |
| 418 | // Wait for any running threads to finish and don't start any others. |
| 419 | // Only relevant if we hit the count limit before reading all the tiles. |
| 420 | m_pool->stop(); |
| 421 | |
| 422 | return numRead; |
| 423 | } |
| 424 | |
| 425 | bool EsriReader::processOne(PointRef& point) |
| 426 | { |