1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 03:42:09 +01:00

Use the same locking algorithm like in IMG/Mapsforge maps

This commit is contained in:
Martin Tůma 2024-12-03 20:25:38 +01:00
parent 240ddaf39c
commit d3889b6dfe

View File

@ -6,31 +6,23 @@ bool AtlasData::pointCb(MapEntry *map, void *context)
{
PointCTX *ctx = (PointCTX*)context;
start:
map->lock.lock();
ctx->cacheLock.lock();
MapData *cached = ctx->cache.object(map->path);
if (!cached) {
ctx->cacheLock.unlock();
if (map->lock.tryLock()) {
MapData *data = new MapData(map->path);
data->points(ctx->rect, ctx->points);
ctx->cacheLock.lock();
ctx->cache.insert(map->path, data);
map->lock.unlock();
} else {
map->lock.lock();
map->lock.unlock();
goto start;
}
} else
cached->points(ctx->rect, ctx->points);
ctx->cacheLock.unlock();
map->lock.unlock();
return true;
}