| OLD | NEW |
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 "The file \"" + file_name.value() + "\" was previously loaded\n" | 196 "The file \"" + file_name.value() + "\" was previously loaded\n" |
| 197 "asynchronously (via a deps rule) and now you're trying to load it " | 197 "asynchronously (via a deps rule) and now you're trying to load it " |
| 198 "synchronously.\nThis is a class 2 misdemeanor: a single input file " | 198 "synchronously.\nThis is a class 2 misdemeanor: a single input file " |
| 199 "must be loaded the same way\neach time to avoid blowing my tiny, " | 199 "must be loaded the same way\neach time to avoid blowing my tiny, " |
| 200 "tiny mind."); | 200 "tiny mind."); |
| 201 return nullptr; | 201 return nullptr; |
| 202 } | 202 } |
| 203 | 203 |
| 204 if (!data->loaded) { | 204 if (!data->loaded) { |
| 205 // Wait for the already-pending sync load to complete. | 205 // Wait for the already-pending sync load to complete. |
| 206 if (!data->completion_event) | 206 if (!data->completion_event) { |
| 207 data->completion_event.reset(new base::WaitableEvent(false, false)); | 207 data->completion_event.reset(new base::WaitableEvent( |
| 208 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 209 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
| 210 } |
| 208 { | 211 { |
| 209 base::AutoUnlock unlock(lock_); | 212 base::AutoUnlock unlock(lock_); |
| 210 data->completion_event->Wait(); | 213 data->completion_event->Wait(); |
| 211 } | 214 } |
| 212 // If there were multiple waiters on the same event, we now need to wake | 215 // If there were multiple waiters on the same event, we now need to wake |
| 213 // up the next one. | 216 // up the next one. |
| 214 data->completion_event->Signal(); | 217 data->completion_event->Signal(); |
| 215 } | 218 } |
| 216 } | 219 } |
| 217 | 220 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 315 |
| 313 // Run pending invocations. Theoretically we could schedule each of these | 316 // Run pending invocations. Theoretically we could schedule each of these |
| 314 // separately to get some parallelism. But normally there will only be one | 317 // separately to get some parallelism. But normally there will only be one |
| 315 // item in the list, so that's extra overhead and complexity for no gain. | 318 // item in the list, so that's extra overhead and complexity for no gain. |
| 316 if (success) { | 319 if (success) { |
| 317 for (const auto& cb : callbacks) | 320 for (const auto& cb : callbacks) |
| 318 cb.Run(unowned_root); | 321 cb.Run(unowned_root); |
| 319 } | 322 } |
| 320 return success; | 323 return success; |
| 321 } | 324 } |
| OLD | NEW |