prevent possible race condition while obtaining collision-free shape ID
This commit is contained in:
parent
0db43ad457
commit
ee948a8810
1 changed files with 2 additions and 1 deletions
|
@ -242,6 +242,7 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) {
|
||||||
|
|
||||||
for (auto t : clusters[i]) {
|
for (auto t : clusters[i]) {
|
||||||
if (_cfg.evaluate && _evalFeed && _ecoll) {
|
if (_cfg.evaluate && _evalFeed && _ecoll) {
|
||||||
|
std::lock_guard<std::mutex> guard(_shpMutex);
|
||||||
_ecoll->add(t, _evalFeed->getShapes().get(t->getShape()), shp,
|
_ecoll->add(t, _evalFeed->getShapes().get(t->getShape()), shp,
|
||||||
distances);
|
distances);
|
||||||
}
|
}
|
||||||
|
@ -249,6 +250,7 @@ void ShapeBuilder::shape(pfaedle::netgraph::Graph* ng) {
|
||||||
if (!t->getShape().empty() && shpUsage[t->getShape()] > 0) {
|
if (!t->getShape().empty() && shpUsage[t->getShape()] > 0) {
|
||||||
shpUsage[t->getShape()]--;
|
shpUsage[t->getShape()]--;
|
||||||
if (shpUsage[t->getShape()] == 0) {
|
if (shpUsage[t->getShape()] == 0) {
|
||||||
|
std::lock_guard<std::mutex> guard(_shpMutex);
|
||||||
_feed->getShapes().remove(t->getShape());
|
_feed->getShapes().remove(t->getShape());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,7 +291,6 @@ void ShapeBuilder::setShape(Trip* t, const ad::cppgtfs::gtfs::Shape& s,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(_shpMutex);
|
std::lock_guard<std::mutex> guard(_shpMutex);
|
||||||
// TODO(patrick):
|
|
||||||
t->setShape(_feed->getShapes().add(s));
|
t->setShape(_feed->getShapes().add(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue