mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 11:52:08 +01:00
Use the same locking algorithm like in IMG/Mapsforge maps
This commit is contained in:
parent
53685253d7
commit
240ddaf39c
@ -39,34 +39,26 @@ bool AtlasData::polyCb(MapEntry *map, void *context)
|
|||||||
{
|
{
|
||||||
PolyCTX *ctx = (PolyCTX*)context;
|
PolyCTX *ctx = (PolyCTX*)context;
|
||||||
|
|
||||||
start:
|
map->lock.lock();
|
||||||
|
|
||||||
ctx->cacheLock.lock();
|
ctx->cacheLock.lock();
|
||||||
|
|
||||||
MapData *cached = ctx->cache.object(map->path);
|
MapData *cached = ctx->cache.object(map->path);
|
||||||
|
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
ctx->cacheLock.unlock();
|
ctx->cacheLock.unlock();
|
||||||
|
|
||||||
if (map->lock.tryLock()) {
|
|
||||||
MapData *data = new MapData(map->path);
|
MapData *data = new MapData(map->path);
|
||||||
data->polygons(ctx->rect, ctx->polygons);
|
data->polygons(ctx->rect, ctx->polygons);
|
||||||
data->lines(ctx->rect, ctx->lines);
|
data->lines(ctx->rect, ctx->lines);
|
||||||
|
|
||||||
ctx->cacheLock.lock();
|
ctx->cacheLock.lock();
|
||||||
ctx->cache.insert(map->path, data);
|
ctx->cache.insert(map->path, data);
|
||||||
|
|
||||||
map->lock.unlock();
|
|
||||||
} else {
|
|
||||||
map->lock.lock();
|
|
||||||
map->lock.unlock();
|
|
||||||
goto start;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
cached->polygons(ctx->rect, ctx->polygons);
|
cached->polygons(ctx->rect, ctx->polygons);
|
||||||
cached->lines(ctx->rect, ctx->lines);
|
cached->lines(ctx->rect, ctx->lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->cacheLock.unlock();
|
ctx->cacheLock.unlock();
|
||||||
|
map->lock.unlock();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user