From 2356021f734ac75339c8a3ff74fab4e892605398 Mon Sep 17 00:00:00 2001 From: Zubair Date: Tue, 18 Feb 2025 18:52:56 +0500 Subject: [PATCH 1/5] unblock the user actions while running the build --- .../eclipse/core/internal/jobs/ThreadJob.java | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java index a7e50344b5b..795fcf6d8a7 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java @@ -208,7 +208,7 @@ static ThreadJob joinRun(ThreadJob threadJob, IProgressMonitor monitor) { boolean interruptedDuringWaitForRun; try { // just return if lock listener decided to grant immediate access - if (manager.getLockManager().aboutToWait(blocker)) { + if (manager.getLockManager().aboutToWait(blocker) || identifyThreadAction()) { return threadJob; } result = waitForRun(threadJob, monitor, blockingJob); @@ -231,6 +231,46 @@ static ThreadJob joinRun(ThreadJob threadJob, IProgressMonitor monitor) { return result; } + + public static boolean identifyThreadAction() { + String threadName = Thread.currentThread().getName(); + Job[] jobs = Job.getJobManager().find(null); + + // Get the job running in the current thread + Job currentJob = null; + for (Job job : jobs) { + if (job.getThread() == Thread.currentThread()) { + currentJob = job; + break; + } + } + + // UI Thread (User interactions) + if (threadName.equals("main")) { //$NON-NLS-1$ + return true; // This is the UI Thread! (Handling direct user interactions) + } + + // Background Worker Threads + if (threadName.contains("Worker")) { //$NON-NLS-1$ + if (currentJob != null) { + String jobName = currentJob.getName(); + + if (jobName.toLowerCase().contains("save") || jobName.toLowerCase().contains("edit")) { //$NON-NLS-1$ //$NON-NLS-2$ + return true; // This thread is handling a FILE SAVE/EDIT operation. + } else if (jobName.toLowerCase().contains("vcs") || jobName.toLowerCase().contains("git") //$NON-NLS-1$ //$NON-NLS-2$ + || jobName.toLowerCase().contains("commit")) { //$NON-NLS-1$ + return true; // This thread is handling a VCS (Version Control) operation. + } else if (jobName.toLowerCase().contains("build") || jobName.toLowerCase().contains("debug")) { //$NON-NLS-1$ //$NON-NLS-2$ + return false; // This thread is handling a BUILD/RUN/DEBUG job. + } else { + return false; // This thread is handling an unknown background job + } + } + } + // If not identified + return false; // Thread not recognized + } + /** * Waits until given {@code ThreadJob} "runs" (acquires the rule conflicting * with given {@code blockingJob} or is canceled. While the given From 55c3d8c25d5c6ebbafaefb5f856d84d6e788f7ef Mon Sep 17 00:00:00 2001 From: Zubair Date: Wed, 19 Feb 2025 18:42:34 +0500 Subject: [PATCH 2/5] optimize the thread - all the UI interactions are now handle by "main" --- .../eclipse/core/internal/jobs/ThreadJob.java | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java index 795fcf6d8a7..fb939bcfabf 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java @@ -234,41 +234,26 @@ static ThreadJob joinRun(ThreadJob threadJob, IProgressMonitor monitor) { public static boolean identifyThreadAction() { String threadName = Thread.currentThread().getName(); - Job[] jobs = Job.getJobManager().find(null); - - // Get the job running in the current thread - Job currentJob = null; - for (Job job : jobs) { - if (job.getThread() == Thread.currentThread()) { - currentJob = job; - break; - } - } + Job currentJob = Job.getJobManager().currentJob(); // UI Thread (User interactions) - if (threadName.equals("main")) { //$NON-NLS-1$ - return true; // This is the UI Thread! (Handling direct user interactions) + if ("main".equals(threadName)) { //$NON-NLS-1$ + return true; } // Background Worker Threads - if (threadName.contains("Worker")) { //$NON-NLS-1$ - if (currentJob != null) { - String jobName = currentJob.getName(); - - if (jobName.toLowerCase().contains("save") || jobName.toLowerCase().contains("edit")) { //$NON-NLS-1$ //$NON-NLS-2$ - return true; // This thread is handling a FILE SAVE/EDIT operation. - } else if (jobName.toLowerCase().contains("vcs") || jobName.toLowerCase().contains("git") //$NON-NLS-1$ //$NON-NLS-2$ - || jobName.toLowerCase().contains("commit")) { //$NON-NLS-1$ - return true; // This thread is handling a VCS (Version Control) operation. - } else if (jobName.toLowerCase().contains("build") || jobName.toLowerCase().contains("debug")) { //$NON-NLS-1$ //$NON-NLS-2$ - return false; // This thread is handling a BUILD/RUN/DEBUG job. - } else { - return false; // This thread is handling an unknown background job - } + if (threadName.contains("Worker") && currentJob != null) { //$NON-NLS-1$ + String jobName = currentJob.getName().toLowerCase(); + if (jobName.contains("build")) { //$NON-NLS-1$ + // This thread is handling a BUILD job + return false; } + // Any other worker-thread job + return false; } - // If not identified - return false; // Thread not recognized + + // Everything else defaults to false + return false; } /** From 20ac84fb79b908bc5ac63a93abdfa23eb50aef0c Mon Sep 17 00:00:00 2001 From: Zubair Date: Tue, 18 Mar 2025 07:35:10 +0500 Subject: [PATCH 3/5] Add isUI method to LockManager for identify UI thread and grant immediate access --- .../core/internal/jobs/LockManager.java | 9 +++++++ .../eclipse/core/internal/jobs/ThreadJob.java | 27 +------------------ .../core/runtime/jobs/LockListener.java | 6 +++++ 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/LockManager.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/LockManager.java index fbfb8c7e779..3e99c96bcd1 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/LockManager.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/LockManager.java @@ -109,6 +109,15 @@ public boolean aboutToWait(Thread lockOwner) { return false; } + public boolean isUI() { + try { + return lockListener.isUI(); + } catch (Exception | LinkageError e) { + handleException(e); + } + return false; + } + /** * This thread has just acquired a lock. Update graph. */ diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java index fb939bcfabf..b191d5e7ef2 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java @@ -208,7 +208,7 @@ static ThreadJob joinRun(ThreadJob threadJob, IProgressMonitor monitor) { boolean interruptedDuringWaitForRun; try { // just return if lock listener decided to grant immediate access - if (manager.getLockManager().aboutToWait(blocker) || identifyThreadAction()) { + if (manager.getLockManager().aboutToWait(blocker) || manager.getLockManager().isUI()) { return threadJob; } result = waitForRun(threadJob, monitor, blockingJob); @@ -231,31 +231,6 @@ static ThreadJob joinRun(ThreadJob threadJob, IProgressMonitor monitor) { return result; } - - public static boolean identifyThreadAction() { - String threadName = Thread.currentThread().getName(); - Job currentJob = Job.getJobManager().currentJob(); - - // UI Thread (User interactions) - if ("main".equals(threadName)) { //$NON-NLS-1$ - return true; - } - - // Background Worker Threads - if (threadName.contains("Worker") && currentJob != null) { //$NON-NLS-1$ - String jobName = currentJob.getName().toLowerCase(); - if (jobName.contains("build")) { //$NON-NLS-1$ - // This thread is handling a BUILD job - return false; - } - // Any other worker-thread job - return false; - } - - // Everything else defaults to false - return false; - } - /** * Waits until given {@code ThreadJob} "runs" (acquires the rule conflicting * with given {@code blockingJob} or is canceled. While the given diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/LockListener.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/LockListener.java index a2a31926d9c..10cbb16c7a3 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/LockListener.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/LockListener.java @@ -46,6 +46,12 @@ public boolean aboutToWait(Thread lockOwner) { return false; } + /** + * @since 3.16 + */ + public boolean isUI() { + return false; + } /** * Notification that a thread is about to release a lock. *

From 7badcec4ebc9667fe1326f2502f28bb28c41a05e Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Tue, 18 Mar 2025 17:08:02 +0000 Subject: [PATCH 4/5] Version bump(s) for 4.36 stream --- runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF index d3660e7a869..4e6320b6b95 100644 --- a/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.jobs; singleton:=true -Bundle-Version: 3.15.500.qualifier +Bundle-Version: 3.15.600.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.jobs;x-internal:=true, From 74ed88ccf2ce86fd8b8a3942dbb4f80cc256d9dd Mon Sep 17 00:00:00 2001 From: Zubair Date: Tue, 8 Apr 2025 17:41:00 +0500 Subject: [PATCH 5/5] Bump Bundle-Version to 3.16.0.qualifier in MANIFEST.MF --- runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF index 4e6320b6b95..934ea90cec8 100644 --- a/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.jobs; singleton:=true -Bundle-Version: 3.15.600.qualifier +Bundle-Version: 3.16.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.jobs;x-internal:=true,