Fix test for races with multiple parallel requests (#3891)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -99,10 +99,12 @@ void GeoJSONSource::loadDescription(FileSource& fileSource) {
|
||||
return makeMutable<Impl>(current, std::move(geoJSONData));
|
||||
},
|
||||
/* onImplReady */
|
||||
[this, self = makeWeakPtr(), capturedReq = req.get()](Immutable<Source::Impl> newImpl) {
|
||||
assert(capturedReq);
|
||||
[this, self = makeWeakPtr(), capturedReqGeneration = ++requestGeneration](
|
||||
Immutable<Source::Impl> newImpl) {
|
||||
assert(capturedReqGeneration);
|
||||
if (auto guard = self.lock(); self) {
|
||||
if (capturedReq == req.get()) { // If a new request is being processed, ignore this impl.
|
||||
if (capturedReqGeneration ==
|
||||
requestGeneration) { // If a new request is being processed, ignore this impl.
|
||||
baseImpl = std::move(newImpl);
|
||||
loaded = true;
|
||||
observer->onSourceLoaded(*this);
|
||||
|
||||
Reference in New Issue
Block a user