From 699e5e2a624059f79d372f078cc39e2adb02eba9 Mon Sep 17 00:00:00 2001 From: sboshev Date: Mon, 3 Aug 2009 15:49:03 +0000 Subject: Bug 282563. [ds] RCP using declarative services (occasionally) hangs for 30 secs on start-up --- .../eclipse/equinox/internal/ds/SCRManager.java | 29 +++++++++++++--------- .../eclipse/equinox/internal/ds/WorkThread.java | 3 +++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java index 233bcfb05..e456995df 100644 --- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java +++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java @@ -629,19 +629,24 @@ public class SCRManager implements ServiceListener, SynchronousBundleListener, C } // store the components in the cache bundleToServiceComponents.put(bundle, components.clone()); - // this will also resolve the component dependencies! - enqueueWork(this, ENABLE_COMPONENTS, components, false); - synchronized (components) { - long startTime = System.currentTimeMillis(); - try { - do { - components.wait(1000); - } while (!components.isEmpty() && (System.currentTimeMillis() - startTime < WorkThread.BLOCK_TIMEOUT)); - if (System.currentTimeMillis() - startTime >= WorkThread.BLOCK_TIMEOUT) { - Activator.log.warning(NLS.bind(Messages.TIMEOUT_REACHED_ENABLING_COMPONENTS, getBundleName(bundle), Integer.toString(WorkThread.BLOCK_TIMEOUT)), null); + if (workThread != null && workThread.processingThread == Thread.currentThread()) { + //we are in the queue thread already. Processing synchronously the job + resolver.enableComponents(components); + } else { + // this will also resolve the component dependencies! + enqueueWork(this, ENABLE_COMPONENTS, components, false); + synchronized (components) { + long startTime = System.currentTimeMillis(); + try { + do { + components.wait(1000); + } while (!components.isEmpty() && (System.currentTimeMillis() - startTime < WorkThread.BLOCK_TIMEOUT)); + if (System.currentTimeMillis() - startTime >= WorkThread.BLOCK_TIMEOUT) { + Activator.log.warning(NLS.bind(Messages.TIMEOUT_REACHED_ENABLING_COMPONENTS, getBundleName(bundle), Integer.toString(WorkThread.BLOCK_TIMEOUT)), null); + } + } catch (InterruptedException e) { + //do nothing } - } catch (InterruptedException e) { - //do nothing } } } diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java index 56ddc0342..7ae2b1d07 100644 --- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java +++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java @@ -31,6 +31,7 @@ public class WorkThread implements Runnable, TimerListener { private SCRManager mgr; private Object objectToProcess; boolean running = true; + Thread processingThread; int waiting = 0; @@ -43,6 +44,7 @@ public class WorkThread implements Runnable, TimerListener { * ManagedService(Factories) are informed for the event. */ public void run() { + processingThread = Thread.currentThread(); do { try { Queue queue = mgr.queue; @@ -97,6 +99,7 @@ public class WorkThread implements Runnable, TimerListener { } } while (running); objectToProcess = null; + processingThread = null; } public void timer(int event) { -- cgit v1.2.3