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

Use thread pools #601

Merged
merged 1 commit into from
Jan 22, 2020
Merged

Use thread pools #601

merged 1 commit into from
Jan 22, 2020

Conversation

jeffdgr8
Copy link
Contributor

Reuse threads from pool instead of creating new thread for every task

Reuse threads from pool instead of creating new thread for every task
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 22, 2020
Copy link
Collaborator

@barbeau barbeau left a comment

Choose a reason for hiding this comment

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

Thanks @jeffdgr8!

@@ -290,7 +293,7 @@ public void run() {
});
renderTask.setProjection(projection);
renderTask.setMapZoom(mMap.getCameraPosition().zoom);
new Thread(renderTask).start();
mExecutor.execute(renderTask);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just calling out for future reference that given this Executor is instantiated via newSingleThreadExecutor() we're changing to single-threading here. But, the entire implementation appears to be effectively single-threaded anyway given the synchronized block and mViewModificationInProgress variable which will stop any other RenderTasks from being executed until this one finishes. So 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my line of thinking exactly. There's only ever one render task in flight and potentially one queued up to run next.

@barbeau barbeau merged commit 6619f14 into googlemaps:master Jan 22, 2020
@jeffdgr8 jeffdgr8 deleted the thread-pools branch January 22, 2020 20:29
@arriolac arriolac added this to the 1.0 milestone Feb 24, 2020
barbeau added a commit that referenced this pull request Mar 19, 2020
This reverts commit 6619f14. It seems that when a thread pool is used it allows a thread to try and unlock() a lock that it did not lock(), which ReentrantLock does not allow - "If the current thread is not the holder of this lock then IllegalMonitorStateException is thrown."

Fixes #660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants