private ReadLock(Sync readLock) throws InterruptedException { this.readLock = readLock; this.readLock.acquire(); }
private ReadLock(Sync readLock) throws InterruptedException { this.readLock = readLock; this.readLock.acquire(); }
/** * Creates a new <code>EventResult</code>. * * @param log log messages are written to this <code>Logger</code>. */ public EventResult(PrintWriter log) { this.log = log; try { sync.acquire(); } catch (InterruptedException e) { log.println("Could not aquire sync."); throw new RuntimeException("EventResult: Interrupted while aquiring sync."); } }
private WriteLock(ReadWriteLock readWriteLock) throws InterruptedException { this.readWriteLock = readWriteLock; this.readWriteLock.writeLock().acquire(); }
/** * When the calling thread returns this index merger will be idle, that is * there will be no merge tasks pending anymore. The method returns immediately * if there are currently no tasks pending at all. */ void waitUntilIdle() throws InterruptedException { mergerIdle.acquire(); // and immediately release again mergerIdle.release(); }
private WriteLock(ReadWriteLock readWriteLock) throws InterruptedException { this.readWriteLock = readWriteLock; this.readWriteLock.writeLock().acquire(); }
/** * Acquires a {@link Sync} ignoring any interruptions. Should any * interruption occur the interruption status will be set. Might * potentially block/wait forever. * * @see Sync#acquire() * @param latch the latch on which to wait */ protected static void acquireIgnoringInterruption(Sync latch) { try { latch.acquire(); } catch (InterruptedException e) { // waken up externally - ignore try again acquireIgnoringInterruption(latch); // be a good citizen and set back the interruption status Thread.currentThread().interrupt(); } }
/** * Acquires a {@link Sync} ignoring any interruptions. Should any * interruption occur the interruption status will be set. Might * potentially block/wait forever. * * @see Sync#acquire() * * @param latch the latch on which to wait */ protected static void acquireIgnoringInterruption(Sync latch) { try { latch.acquire(); } catch (InterruptedException e) { // waken up externally - ignore try again acquireIgnoringInterruption(latch); // be a good citizen and set back the interruption status Thread.currentThread().interrupt(); } }
public void release() { Sync exclusive = writerStateRWLock.writeLock(); for (;;) { try { exclusive.acquire(); break; } catch (InterruptedException e) { // try again Thread.interrupted(); } } try { activeWriter = null; activeWriterId = null; notifyWaitingReaders(); notifyWaitingWriters(); } finally { exclusive.release(); } }
/** * Creates an <code>IndexMerger</code>. * * @param multiIndex the <code>MultiIndex</code>. */ IndexMerger(MultiIndex multiIndex) { this.multiIndex = multiIndex; setName("Index Merger" + (multiIndex.workspaceId == null ? "" : " " + multiIndex.workspaceId)); setDaemon(true); try { mergerIdle.acquire(); } catch (InterruptedException e) { // will never happen, lock is free upon construction throw new InternalError("Unable to acquire mutex after construction"); } }
public void release() { Sync exclusive = writerStateRWLock.writeLock(); for (;;) { try { exclusive.acquire(); break; } catch (InterruptedException e) { // try again Thread.interrupted(); } } try { activeWriter = null; activeWriterId = null; notifyWaitingReaders(); notifyWaitingWriters(); } finally { exclusive.release(); } }
public ReadLock downgrade() { readerCount.incrementAndGet(); readLockMap.addLock(null); Sync exclusive = writerStateRWLock.writeLock(); for (;;) { try { exclusive.acquire(); break; } catch (InterruptedException e) { // try again Thread.interrupted(); } } try { activeWriter = null; // only notify waiting readers since we still hold a down // graded lock, which is kind of exclusiv with respect to // other writers notifyWaitingReaders(); } finally { exclusive.release(); } return anonymousReadLock; }
public ReadLock downgrade() { readerCount.incrementAndGet(); readLockMap.addLock(null); Sync exclusive = writerStateRWLock.writeLock(); for (;;) { try { exclusive.acquire(); break; } catch (InterruptedException e) { // try again Thread.interrupted(); } } try { activeWriter = null; // only notify waiting readers since we still hold a down // graded lock, which is kind of exclusiv with respect to // other writers notifyWaitingReaders(); } finally { exclusive.release(); } return anonymousReadLock; }
/** * Shuts down this repository. The shutdown is guarded by a shutdown lock * that prevents any new sessions from being started simultaneously. */ public void shutdown() { try { shutdownLock.writeLock().acquire(); } catch (InterruptedException e) { // TODO: Should this be a checked exception? throw new RuntimeException("Shutdown lock could not be acquired", e); } try { // check status of this instance if (!disposed) { doShutdown(); } } finally { shutdownLock.writeLock().release(); } }
public int size() { Sync sync = this.lock.readLock(); try { sync.acquire(); try { return this.doGetSize(); } finally { sync.release(); } } catch (InterruptedException ignore) { return 0; } }
/** * Shuts down this repository. The shutdown is guarded by a shutdown lock * that prevents any new sessions from being started simultaneously. */ public void shutdown() { try { shutdownLock.writeLock().acquire(); } catch (InterruptedException e) { // TODO: Should this be a checked exception? throw new RuntimeException("Shutdown lock could not be acquired", e); } try { // check status of this instance if (!disposed) { doShutdown(); } } finally { shutdownLock.writeLock().release(); } }
public synchronized Object getObject(final Object key) throws IOException, ClassNotFoundException { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { final File file = this.fileFromKey(key); if (file != null) { return this.deserializeObject(file); } } finally { sync.release(); } } catch (InterruptedException ignore) { } return null; }
private void internalSync(boolean startup) throws JournalException { try { rwLock.readLock().acquire(); } catch (InterruptedException e) { String msg = "Unable to acquire read lock."; throw new JournalException(msg, e); } try { doSync(getMinimalRevision(), startup); } finally { rwLock.readLock().release(); } }
private void internalSync(boolean startup) throws JournalException { try { rwLock.readLock().acquire(); } catch (InterruptedException e) { String msg = "Unable to acquire read lock."; throw new JournalException(msg, e); } try { doSync(getMinimalRevision(), startup); } finally { rwLock.readLock().release(); } }
/** * Frees some values of the data file.<br> */ public void free() { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doFree(); m_sizeInstrument.setValue( doGetSize() ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }