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

Side by Side Diff: tools/gn/input_file_manager.cc

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/gyp_target_writer.cc ('k') | tools/gn/item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/input_file_manager.h" 5 #include "tools/gn/input_file_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/parser.h" 10 #include "tools/gn/parser.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 if (!data->loaded) { 147 if (!data->loaded) {
148 // Wait for the already-pending sync load to complete. 148 // Wait for the already-pending sync load to complete.
149 if (!data->completion_event) 149 if (!data->completion_event)
150 data->completion_event.reset(new base::WaitableEvent(false, false)); 150 data->completion_event.reset(new base::WaitableEvent(false, false));
151 { 151 {
152 base::AutoUnlock unlock(lock_); 152 base::AutoUnlock unlock(lock_);
153 data->completion_event->Wait(); 153 data->completion_event->Wait();
154 } 154 }
155 // If there were multiple waiters on the same event, we now need to wake
156 // up the next one.
157 data->completion_event->Signal();
155 } 158 }
156 } 159 }
157 160
158 // The other load could have failed. In this case that error will be printed 161 // The other load could have failed. In this case that error will be printed
159 // to the console, but we need to return something here, so make up a 162 // to the console, but we need to return something here, so make up a
160 // dummy error. 163 // dummy error.
161 if (!data->parsed_root) 164 if (!data->parsed_root)
162 *err = Err(origin, "File parse failed"); 165 *err = Err(origin, "File parse failed");
163 return data->parsed_root.get(); 166 return data->parsed_root.get();
164 } 167 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 callbacks.swap(data->scheduled_callbacks); 270 callbacks.swap(data->scheduled_callbacks);
268 } 271 }
269 272
270 // Run pending invocations. Theoretically we could schedule each of these 273 // Run pending invocations. Theoretically we could schedule each of these
271 // separately to get some parallelism. But normally there will only be one 274 // separately to get some parallelism. But normally there will only be one
272 // item in the list, so that's extra overhead and complexity for no gain. 275 // item in the list, so that's extra overhead and complexity for no gain.
273 for (size_t i = 0; i < callbacks.size(); i++) 276 for (size_t i = 0; i < callbacks.size(); i++)
274 callbacks[i].Run(unowned_root); 277 callbacks[i].Run(unowned_root);
275 return true; 278 return true;
276 } 279 }
OLDNEW
« no previous file with comments | « tools/gn/gyp_target_writer.cc ('k') | tools/gn/item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698