Chromium Code Reviews| Index: gin/modules/module_registry.cc |
| diff --git a/gin/modules/module_registry.cc b/gin/modules/module_registry.cc |
| index 3712f1a41ac79fe29a33fcfadd73ee4a2d52ed42..cfb5291c0df4fc7bc006e9e98b018b65ad095540 100644 |
| --- a/gin/modules/module_registry.cc |
| +++ b/gin/modules/module_registry.cc |
| @@ -167,9 +167,7 @@ void ModuleRegistry::LoadModule(Isolate* isolate, |
| callback.Run(GetModule(isolate, id)); |
| return; |
| } |
| - // Should we support multiple callers waiting on the same module? |
| - DCHECK(waiting_callbacks_.find(id) == waiting_callbacks_.end()); |
| - waiting_callbacks_[id] = callback; |
| + waiting_callbacks_.insert(std::make_pair(id, callback)); |
| unsatisfied_dependencies_.insert(id); |
| } |
| @@ -184,13 +182,20 @@ void ModuleRegistry::RegisterModule(Isolate* isolate, |
| v8::Handle<Object> modules = Local<Object>::New(isolate, modules_); |
| modules->Set(StringToSymbol(isolate, id), module); |
| - LoadModuleCallbackMap::iterator it = waiting_callbacks_.find(id); |
| - if (it == waiting_callbacks_.end()) |
| - return; |
| - LoadModuleCallback callback = it->second; |
| - waiting_callbacks_.erase(it); |
| - // Should we call the callback asynchronously? |
| - callback.Run(module); |
| + std::pair<LoadModuleCallbackMap::iterator, LoadModuleCallbackMap::iterator> |
| + range = waiting_callbacks_.equal_range(id); |
| + std::vector<LoadModuleCallback> callbacks; |
|
abarth-chromium
2014/07/08 14:20:30
Can you preallocate the correct number of slots in
Sam McNally
2014/07/09 00:22:51
Done.
|
| + for (LoadModuleCallbackMap::iterator it = range.first; it != range.second; |
| + ++it) { |
| + callbacks.push_back(it->second); |
| + } |
| + waiting_callbacks_.erase(range.first, range.second); |
| + for (std::vector<LoadModuleCallback>::iterator it = callbacks.begin(); |
| + it != callbacks.end(); |
| + ++it) { |
| + // Should we call the callback asynchronously? |
| + it->Run(module); |
| + } |
| } |
| bool ModuleRegistry::CheckDependencies(PendingModule* pending) { |