Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multithread locker for tagGroup (cities in search) #801

Open
wants to merge 1 commit into
base: r4.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions include/OsmAndCore/Data/ObfPoiSectionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <OsmAndCore/QtExtensions.h>
#include <QList>
#include <QStringList>
#include <QReadWriteLock>

#include <OsmAndCore.h>
#include <OsmAndCore/CommonTypes.h>
#include <OsmAndCore/Data/DataCommonTypes.h>
#include <OsmAndCore/Data/ObfSectionInfo.h>
#include <OsmAndCore/QuadTree.h>

namespace OsmAnd
{
Expand Down Expand Up @@ -77,8 +77,6 @@ namespace OsmAnd
friend class OsmAnd::ObfPoiSectionReader_P;
};

typedef OsmAnd::QuadTree<int32_t, AreaI::CoordType> BBoxIndexTree;

class ObfPoiSectionInfo_P;
class OSMAND_CORE_API ObfPoiSectionInfo : public ObfSectionInfo
{
Expand All @@ -97,6 +95,7 @@ namespace OsmAnd
uint32_t subtypesInnerOffset;
uint32_t firstBoxInnerOffset;
mutable QHash<uint32_t, QList<QPair<QString, QString>>> tagGroups;
mutable QReadWriteLock _tagGroupsLock;

std::shared_ptr<const ObfPoiSectionCategories> getCategories() const;
std::shared_ptr<const ObfPoiSectionSubtypes> getSubtypes() const;
Expand Down
15 changes: 8 additions & 7 deletions src/Data/ObfPoiSectionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ std::shared_ptr<const OsmAnd::ObfPoiSectionSubtypes> OsmAnd::ObfPoiSectionInfo::

QList<QPair<QString, QString>> OsmAnd::ObfPoiSectionInfo::getTagValues(uint32_t id) const
{
auto it = tagGroups.find(id);
if (it != tagGroups.end())
QList<QPair<QString, QString>> res;
{
return *it;
}
else
{
return QList<QPair<QString, QString>>();
QReadLocker tagGroupsLocker(&_tagGroupsLock);
auto it = tagGroups.find(id);
if (it != tagGroups.end())
{
res = *it;
}
}
return res;
}

OsmAnd::ObfPoiSectionCategories::ObfPoiSectionCategories()
Expand Down
5 changes: 4 additions & 1 deletion src/Data/ObfPoiSectionReader_P.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,10 @@ bool OsmAnd::ObfPoiSectionReader_P::scanTiles(
const auto old = cis->PushLimit(tagGroupLength);
QHash<uint32_t, QList<QPair<QString, QString>>> localTagGroups;
readTagGroups(reader, localTagGroups);
//section->tagGroups.insert(localTagGroups);
{
QWriteLocker tagGroupsLocker(&section->_tagGroupsLock);
section->tagGroups.insert(localTagGroups);
}
cis->PopLimit(old);
break;
}
Expand Down