/** * Just record that this workspace is being used, without paying any attention to the synchronization support. */ public synchronized Lease record(@Nonnull FilePath p) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "recorded " + p, new Throwable("from " + this)); } Entry old = inUse.put(p, new Entry(p, false)); if (old!=null) throw new AssertionError("Tried to record a workspace already owned: "+old); return lease(p); }
/** * See {@link #acquire(FilePath,boolean)} * * @param context * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.) * This allows related executors to share the same workspace. */ public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object context) throws InterruptedException { Entry e; Thread t = Thread.currentThread(); String oldName = t.getName(); t.setName("Waiting to acquire "+p+" : "+t.getName()); try { while (true) { e = inUse.get(p); if (e==null || e.context==context) break; wait(); } } finally { t.setName(oldName); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "acquired " + p + (e == null ? "" : " with lock count " + e.lockCount), new Throwable("from " + this)); } if (e!=null) e.lockCount++; else inUse.put(p,new Entry(p,quick,context)); return lease(p); }
/** * Just record that this workspace is being used, without paying any attention to the synchronization support. */ public synchronized Lease record(@Nonnull FilePath p) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "recorded " + p, new Throwable("from " + this)); } Entry old = inUse.put(p, new Entry(p, false)); if (old!=null) throw new AssertionError("Tried to record a workspace already owned: "+old); return lease(p); }
/** * Just record that this workspace is being used, without paying any * attention to the sycnhronization support. */ public synchronized Lease record(FilePath p) { log("recorded " + p); Entry old = inUse.put(p, new Entry(p, false)); if (old != null) { throw new AssertionError("Tried to record a workspace already owned: " + old); } return lease(p); }
/** * Just record that this workspace is being used, without paying any attention to the sycnhronization support. */ public synchronized Lease record(FilePath p) { log("recorded "+p); Entry old = inUse.put(p, new Entry(p, false)); if (old!=null) throw new AssertionError("Tried to record a workspace already owned: "+old); return lease(p); }
/** * Just record that this workspace is being used, without paying any attention to the sycnhronization support. */ public synchronized Lease record(FilePath p) { log("recorded "+p); Entry old = inUse.put(p, new Entry(p, false)); if (old!=null) throw new AssertionError("Tried to record a workspace already owned: "+old); return lease(p); }
/** * Just record that this workspace is being used, without paying any attention to the sycnhronization support. */ public synchronized Lease record(FilePath p) { log("recorded "+p); Entry old = inUse.put(p, new Entry(p, false)); if (old!=null) throw new AssertionError("Tried to record a workspace already owned: "+old); return lease(p); }
/** * See {@link #acquire(FilePath)} * * @param quick * If true, indicates that the acquired workspace will be returned quickly. * This makes other calls to {@link #allocate(FilePath)} to wait for the release of this workspace. */ public synchronized Lease acquire(FilePath p, boolean quick) throws InterruptedException { while (inUse.containsKey(p)) wait(); log("acquired "+p); inUse.put(p,new Entry(p,quick)); return lease(p); }
/** * See {@link #acquire(FilePath)} * * @param quick * If true, indicates that the acquired workspace will be returned quickly. * This makes other calls to {@link #allocate(FilePath)} to wait for the release of this workspace. */ public synchronized Lease acquire(FilePath p, boolean quick) throws InterruptedException { while (inUse.containsKey(p)) wait(); log("acquired "+p); inUse.put(p,new Entry(p,quick)); return lease(p); }
/** * See {@link #acquire(FilePath)} * * @param quick If true, indicates that the acquired workspace will be * returned quickly. This makes other calls to {@link #allocate(FilePath)} * to wait for the release of this workspace. */ public synchronized Lease acquire(FilePath p, boolean quick) throws InterruptedException { while (inUse.containsKey(p)) { wait(); } log("acquired " + p); inUse.put(p, new Entry(p, quick)); return lease(p); }
/** * See {@link #acquire(FilePath,boolean)} * * @param context * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.) * This allows related executors to share the same workspace. */ public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object context) throws InterruptedException { Entry e; Thread t = Thread.currentThread(); String oldName = t.getName(); t.setName("Waiting to acquire "+p+" : "+t.getName()); try { while (true) { e = inUse.get(p); if (e==null || e.context==context) break; wait(); } } finally { t.setName(oldName); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "acquired " + p + (e == null ? "" : " with lock count " + e.lockCount), new Throwable("from " + this)); } if (e!=null) e.lockCount++; else inUse.put(p,new Entry(p,quick,context)); return lease(p); }
/** * See {@link #acquire(FilePath)} * * @param quick * If true, indicates that the acquired workspace will be returned quickly. * This makes other calls to {@link #allocate(FilePath)} to wait for the release of this workspace. */ public synchronized Lease acquire(FilePath p, boolean quick) throws InterruptedException { while (inUse.containsKey(p)) wait(); log("acquired "+p); inUse.put(p,new Entry(p,quick)); return lease(p); }