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:
parent
53685253d7
commit
240ddaf39c
@ -39,34 +39,26 @@ bool AtlasData::polyCb(MapEntry *map, void *context)
|
||||
{
|
||||
PolyCTX *ctx = (PolyCTX*)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->polygons(ctx->rect, ctx->polygons);
|
||||
data->lines(ctx->rect, ctx->lines);
|
||||
MapData *data = new MapData(map->path);
|
||||
data->polygons(ctx->rect, ctx->polygons);
|
||||
data->lines(ctx->rect, ctx->lines);
|
||||
|
||||
ctx->cacheLock.lock();
|
||||
ctx->cache.insert(map->path, data);
|
||||
|
||||
map->lock.unlock();
|
||||
} else {
|
||||
map->lock.lock();
|
||||
map->lock.unlock();
|
||||
goto start;
|
||||
}
|
||||
ctx->cacheLock.lock();
|
||||
ctx->cache.insert(map->path, data);
|
||||
} else {
|
||||
cached->polygons(ctx->rect, ctx->polygons);
|
||||
cached->lines(ctx->rect, ctx->lines);
|
||||
}
|
||||
|
||||
ctx->cacheLock.unlock();
|
||||
map->lock.unlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user