Exemple #1
0
void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
{
    Log::trace() << "Removing invalidated tiles: part: " << part
                 << ", x: " << x << ", y: " << y
                 << ", width: " << width
                 << ", height: " << height << Log::end;

    File dir(_cacheDir);

    std::unique_lock<std::mutex> lock(_cacheMutex);
    std::unique_lock<std::mutex> lockSubscribers(_tilesBeingRenderedMutex);

    if (dir.exists() && dir.isDirectory())
    {
        for (auto tileIterator = DirectoryIterator(dir); tileIterator != DirectoryIterator(); ++tileIterator)
        {
            const std::string fileName = tileIterator.path().getFileName();
            if (intersectsTile(fileName, part, x, y, width, height))
            {
                Log::debug("Removing tile: " + tileIterator.path().toString());
                Util::removeFile(tileIterator.path());
            }
        }
    }

    // Forget this tile as it will have to be rendered again.
    for (auto it = _tilesBeingRendered.begin(); it != _tilesBeingRendered.end(); )
    {
        const std::string cachedName = it->first;
        if (intersectsTile(cachedName, part, x, y, width, height))
        {
            Log::debug("Removing subscriptions for: " + cachedName);
            it = _tilesBeingRendered.erase(it);
        }
        else
        {
            ++it;
        }
    }
}
Exemple #2
0
void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
{
    Log::trace() << "Removing invalidated tiles: part: " << part
                 << ", x: " << x << ", y: " << y
                 << ", width: " << width
                 << ", height: " << height << Log::end;

    File dir(_cacheDir);
    if (dir.exists() && dir.isDirectory())
    {
        std::unique_lock<std::mutex> lock(_cacheMutex);
        for (auto tileIterator = DirectoryIterator(dir); tileIterator != DirectoryIterator(); ++tileIterator)
        {
            const std::string fileName = tileIterator.path().getFileName();
            if (intersectsTile(fileName, part, x, y, width, height))
            {
                Log::debug("Removing tile: " + tileIterator.path().toString());
                Util::removeFile(tileIterator.path());
            }
        }
    }
}