Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Mutex guard annotation manager for cross thread usage#9220

Merged
ivovandongen merged 1 commit into
masterfrom
annotation-manager-mutexed
Jun 13, 2017
Merged

Mutex guard annotation manager for cross thread usage#9220
ivovandongen merged 1 commit into
masterfrom
annotation-manager-mutexed

Conversation

@ivovandongen
Copy link
Copy Markdown
Contributor

Alternative for #9208 to make annotations thread safe for asynchronous rendering (#8820)

@ivovandongen ivovandongen self-assigned this Jun 8, 2017
@ivovandongen ivovandongen requested a review from jfirebaugh June 8, 2017 09:55
@ivovandongen ivovandongen added the Core The cross-platform C++ core, aka mbgl label Jun 8, 2017
Update AnnotationManager::update(const AnnotationID& id, const SymbolAnnotation& annotation, const uint8_t maxZoom) {
Update result = Update::Nothing;

mutex.lock();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual locking/unlocking will leave a stranded lock in the early exit case. (It's an error case, but still best not to corrupt the object internals.)

}
mutex.unlock();

removeAndAdd(id, annotation, maxZoom);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a lock in removeAndAdd around both the remove and add, not merely a lock in add and a lock in remove. Otherwise, a tile could get updated in between the remove and the add, producing a flickering annotation.

@ivovandongen ivovandongen force-pushed the annotation-manager-mutexed branch from 50c10ee to 2d525de Compare June 12, 2017 11:28
@ivovandongen
Copy link
Copy Markdown
Contributor Author

@jfirebaugh Thanks for the review. I've factored out a private remove method that is reused by the removeAnnotation and removeAndAdd methods. Locking is now on all public methods.

@ivovandongen ivovandongen mentioned this pull request Jun 12, 2017
28 tasks
@ivovandongen ivovandongen merged commit 672ba51 into master Jun 13, 2017
@ivovandongen ivovandongen deleted the annotation-manager-mutexed branch June 13, 2017 07:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants