| 423 | } |
| 424 | |
| 425 | bool EsriReader::processOne(PointRef& point) |
| 426 | { |
| 427 | top: |
| 428 | if (m_tilesToProcess == 0) |
| 429 | return false; |
| 430 | |
| 431 | // If there is no active tile, grab one off the queue and ask for |
| 432 | // another if there are more. If none are available, wait. |
| 433 | if (!m_currentTile) |
| 434 | { |
| 435 | do |
| 436 | { |
| 437 | std::unique_lock<std::mutex> l(m_mutex); |
| 438 | if (m_contents.size()) |
| 439 | { |
| 440 | m_currentTile.reset( |
| 441 | new TileContents(std::move(m_contents.front()))); |
| 442 | m_contents.pop(); |
| 443 | l.unlock(); |
| 444 | if (m_curNodeIdx < m_nodes.size()) |
| 445 | load(m_nodes[m_curNodeIdx++]); |
| 446 | break; |
| 447 | } |
| 448 | else |
| 449 | m_contentsCv.wait(l); |
| 450 | } while (true); |
| 451 | checkTile(*m_currentTile); |
| 452 | } |
| 453 | |
| 454 | bool ok = processPoint(point, *m_currentTile); |
| 455 | |
| 456 | // If we've processed all the points in the current tile, pop it. |
| 457 | // If we've processed all the tiles, return false to indicate that |
| 458 | // we're done. |
| 459 | if (m_pointId == m_currentTile->size()) |
| 460 | { |
| 461 | m_pointId = 0; |
| 462 | m_currentTile.reset(); |
| 463 | --m_tilesToProcess; |
| 464 | } |
| 465 | |
| 466 | // If we didn't pass a point, try again. |
| 467 | if (!ok) |
| 468 | goto top; |
| 469 | |
| 470 | return true; |
| 471 | } |
| 472 | |
| 473 | |
| 474 | void EsriReader::process(PointViewPtr dstView, const TileContents& tile, |