Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4525)

Unified Diff: cc/tiles/image_controller_unittest.cc

Issue 2640553003: cc: Fix a hang in image controller unittests by release task lock. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/image_controller_unittest.cc
diff --git a/cc/tiles/image_controller_unittest.cc b/cc/tiles/image_controller_unittest.cc
index b963ff1c9aa53fb826a310edd3d6837290164382..ddd537617a2a4cc5d891466d344dbdfa9081ed97 100644
--- a/cc/tiles/image_controller_unittest.cc
+++ b/cc/tiles/image_controller_unittest.cc
@@ -21,17 +21,21 @@ class TestWorkerThread : public base::SimpleThread {
void Run() override {
for (;;) {
- base::AutoLock hold(lock_);
- if (shutdown_)
- break;
-
- if (queue_.empty()) {
- condition_.Wait();
- continue;
+ base::Closure task;
+ {
+ base::AutoLock hold(lock_);
+ if (shutdown_)
+ break;
+
+ if (queue_.empty()) {
+ condition_.Wait();
+ continue;
+ }
+
+ task = queue_.front();
+ queue_.erase(queue_.begin());
}
-
- queue_.front().Run();
- queue_.erase(queue_.begin());
+ task.Run();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698