Skip to content

Commit

Permalink
Merge pull request #5347 from pkriens/issue/mac-m1
Browse files Browse the repository at this point in the history
[mac m1] Added a bndrun file for the m1
  • Loading branch information
pkriens committed Sep 16, 2022
2 parents 5853f25 + 3891f7d commit ef2175d
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 2 deletions.
13 changes: 13 additions & 0 deletions biz.aQute.bndlib/src/aQute/bnd/build/WorkspaceLock.java
Expand Up @@ -5,9 +5,11 @@
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -29,6 +31,7 @@ final class WorkspaceLock extends ReentrantReadWriteLock {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(WorkspaceLock.class);
private final AtomicInteger progress = new AtomicInteger();
private final List<Thread> readHolders = new CopyOnWriteArrayList<>();

WorkspaceLock(boolean fair) {
super(fair);
Expand Down Expand Up @@ -130,7 +133,16 @@ <T, U> T writeReadLocked(final long timeoutInMs, final Callable<U> underWrite,

<T> T locked(final Lock lock, final long timeoutInMs, final Callable<T> callable, final BooleanSupplier canceled)
throws Exception {
Thread thread = Thread.currentThread();
boolean interrupted = Thread.interrupted();
boolean write = lock == writeLock();
if (write) {
if (readHolders.contains(thread))
throw new IllegalStateException("About to enter a deadlock situation. The thread " + thread
+ " that already holds a read lock attempts to acquire the workspace write lock.");
} else
readHolders.add(thread);

trace("Enter", lock);
try {
int startingProgress = progress.get();
Expand Down Expand Up @@ -169,6 +181,7 @@ <T> T locked(final Lock lock, final long timeoutInMs, final Callable<T> callable
throw timeout(lock);
} finally {
trace("Exit", lock);
readHolders.remove(thread);
if (interrupted) {
Thread.currentThread()
.interrupt();
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
Expand Down Expand Up @@ -305,9 +306,12 @@ protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor
processor.close();
});
if (model.isCnf()) {
model.getWorkspace()
Job job = Job.create("refresh workspace", (m) -> {
model.getWorkspace()
.refresh(); // this is for bnd plugins built in
// cnf
// cnf
});
job.schedule(10);
}
return null;
}, monitor);
Expand Down

0 comments on commit ef2175d

Please sign in to comment.