diff -r 169438d6585b core.startup/apichanges.xml
--- a/core.startup/apichanges.xml Tue Aug 02 11:20:23 2011 +0200
+++ b/core.startup/apichanges.xml Wed Aug 03 15:52:14 2011 +0200
@@ -56,6 +56,22 @@
+
+
+ Invoke ModuleInstalls in parallel
+
+
+
+
+
+
+ New branding key
+ PARALLEL_MODULE_INSTALL
+ is available to run
+ ModuleInstalls in parallel.
+
+
+
netbeans.bootdelegation property
diff -r 169438d6585b core.startup/arch.xml
--- a/core.startup/arch.xml Tue Aug 02 11:20:23 2011 +0200
+++ b/core.startup/arch.xml Wed Aug 03 15:52:14 2011 +0200
@@ -643,6 +643,23 @@
can be accessed. Available since version 1.26.
+
+
+ Applications built on top of NetBeans Platform may request execution
+ of all
+ ModuleInstall in parallel. This usually speeds up start of the
+ application on modern multi core computers, however it requires
+ more robustness and code polishing, as the execution order is more
+ or less random.
+
+
+ To request parallel execution brand the
+ org/netbeans/core/startup/Bundle
file and change value
+ of PARALLEL_MODULE_INSTALL
to the number of
+
+ ModuleInstalls that may run concurrently.
+
+
diff -r 169438d6585b core.startup/manifest.mf
--- a/core.startup/manifest.mf Tue Aug 02 11:20:23 2011 +0200
+++ b/core.startup/manifest.mf Wed Aug 03 15:52:14 2011 +0200
@@ -3,5 +3,5 @@
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/startup/Bundle.properties
OpenIDE-Module-Layer: org/netbeans/core/startup/layer.xml
OpenIDE-Module-Provides: org.openide.modules.InstalledFileLocator
-OpenIDE-Module-Specification-Version: 1.33
+OpenIDE-Module-Specification-Version: 1.34
diff -r 169438d6585b core.startup/src/org/netbeans/core/startup/Bundle.properties
--- a/core.startup/src/org/netbeans/core/startup/Bundle.properties Tue Aug 02 11:20:23 2011 +0200
+++ b/core.startup/src/org/netbeans/core/startup/Bundle.properties Wed Aug 03 15:52:14 2011 +0200
@@ -233,3 +233,7 @@
# {3} - line #
EXC_sax_parse_col_line=Parse error in file {1} line {3} column {2} (PUBLIC {0})
+# Do we want paralelism while installing modules? Zero means no.
+# NOI18N
+PARALLEL_MODULE_INSTALL=0
+
diff -r 169438d6585b core.startup/src/org/netbeans/core/startup/NbInstaller.java
--- a/core.startup/src/org/netbeans/core/startup/NbInstaller.java Tue Aug 02 11:20:23 2011 +0200
+++ b/core.startup/src/org/netbeans/core/startup/NbInstaller.java Wed Aug 03 15:52:14 2011 +0200
@@ -92,6 +92,8 @@
import org.openide.util.NbCollections;
import org.openide.util.SharedClassObject;
import org.openide.util.NbBundle;
+import org.openide.util.RequestProcessor;
+import org.openide.util.RequestProcessor.Task;
import org.openide.util.Utilities;
import org.openide.util.lookup.InstanceContent;
import org.xml.sax.SAXException;
@@ -361,9 +363,12 @@
Main.initUICustomizations();
ev.log(Events.PERF_START, "NbInstaller.load - ModuleInstalls"); // NOI18N
+
+ RequestProcessor rp = createModuleInstallProcessor();
+ Set waitFor = new HashSet();
for (Module m: modules) {
try {
- loadCode(m, true);
+ waitFor.add(loadCode(m, true, rp));
} catch (Exception t) {
Util.err.log(Level.SEVERE, null, t);
} catch (LinkageError le) {
@@ -371,22 +376,31 @@
} catch (AssertionError e) {
Util.err.log(Level.SEVERE, null, e);
}
- ev.log(Events.PERF_TICK, "ModuleInstall for " + m.getCodeName() + " called"); // NOI18N
+ ev.log(Events.PERF_TICK, "ModuleInstall for " + m.getCodeName() + " called"); // NOI18N
}
- ev.log(Events.PERF_END, "NbInstaller.load - ModuleInstalls"); // NOI18N
- ev.log(Events.FINISH_LOAD, modules);
if (Boolean.getBoolean("netbeans.preresolve.classes")) {
preresolveClasses(modules);
}
+
+ for (Task t : waitFor) {
+ if (t != null) {
+ t.waitFinished();
+ }
+ }
+ ev.log(Events.PERF_END, "NbInstaller.load - ModuleInstalls"); // NOI18N
+ ev.log(Events.FINISH_LOAD, modules);
}
+ @Override
public void unload(List modules) {
ev.log(Events.START_UNLOAD, modules);
+ RequestProcessor rp = createModuleInstallProcessor();
+ Set waitFor = new HashSet();
for (Module m: modules) {
try {
- loadCode(m, false);
+ waitFor.add(loadCode(m, false, rp));
} catch (Exception t) {
Util.err.log(Level.SEVERE, null, t);
} catch (LinkageError le) {
@@ -412,23 +426,39 @@
}
}
loadLayers(modules, false);
+ for (Task t : waitFor) {
+ if (t != null) {
+ t.waitFinished();
+ }
+ }
ev.log(Events.FINISH_UNLOAD, modules);
}
/** Load/unload installer code for a module. */
@SuppressWarnings("deprecation") // old ModuleInstall methods we have to call
- private void loadCode(Module m, boolean load) throws Exception {
- Class extends ModuleInstall> instClazz = installs.get(m);
+ private Task loadCode(final Module m, final boolean load, RequestProcessor rp) throws Exception {
+ final Class extends ModuleInstall> instClazz = installs.get(m);
if (instClazz != null) {
- ModuleInstall inst = SharedClassObject.findObject(instClazz, true);
- if (load) {
- ev.log(Events.RESTORE, m);
- inst.restored();
- } else {
- ev.log(Events.UNINSTALL, m);
- inst.uninstalled();
+ final Runnable operation = new Runnable() {
+ @Override
+ public void run() {
+ ModuleInstall inst = SharedClassObject.findObject(instClazz, true);
+ if (load) {
+ ev.log(Events.RESTORE, m);
+ inst.restored();
+ } else {
+ ev.log(Events.UNINSTALL, m);
+ inst.uninstalled();
+ }
+ }
+ };
+ if (rp == null) {
+ operation.run();
+ return null;
}
+ return rp.post(operation);
}
+ return null;
}
/** Load/unload all manifest sections for a given module. */
@@ -484,6 +514,11 @@
}
private final InstanceContent.Convertor convertor = new Convertor();
+
+ private RequestProcessor createModuleInstallProcessor() {
+ int throughput = Integer.parseInt(NbBundle.getMessage(NbInstaller.class, "PARALLEL_MODULE_INSTALL"));
+ return throughput <= 0 ? null : new RequestProcessor("Module Installs", throughput); // NOI18N
+ }
private final class Convertor implements InstanceContent.Convertor { // or ?
Convertor() {}
public Object convert(ManifestSection s) {
diff -r 169438d6585b ide.branding/core.startup/src/org/netbeans/core/startup/Bundle_nb.properties
--- a/ide.branding/core.startup/src/org/netbeans/core/startup/Bundle_nb.properties Tue Aug 02 11:20:23 2011 +0200
+++ b/ide.branding/core.startup/src/org/netbeans/core/startup/Bundle_nb.properties Wed Aug 03 15:52:14 2011 +0200
@@ -78,3 +78,6 @@
MSG_warning=NetBeans IDE - Warning
MSG_info=NetBeans IDE - Information
+
+# NOI18N
+PARALLEL_MODULE_INSTALL=16