private WriteLock(ReadWriteLock readWriteLock) throws InterruptedException { this.readWriteLock = readWriteLock; this.readWriteLock.writeLock().acquire(); }
private WriteLock(ReadWriteLock readWriteLock) throws InterruptedException { this.readWriteLock = readWriteLock; this.readWriteLock.writeLock().acquire(); }
public void release() { readWriteLock.writeLock().release(); }
public void release() { readWriteLock.writeLock().release(); }
/** * 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(); } }
/** * 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 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 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(); } }
/** * Disposes all objects this <code>WorkspaceInfo</code> is holding. */ final void dispose() { try { initLock.writeLock().acquire(); } catch (InterruptedException e) { throw new IllegalStateException("Unable to aquire write lock."); } try { if (!initialized) { // nothing to dispose of, we're already done return; } log.info("shutting down workspace '" + getName() + "'..."); doDispose(); // reset idle timestamp idleTimestamp = 0; active = false; initialized = false; log.info("workspace '" + getName() + "' has been shutdown"); } finally { initLock.writeLock().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; }
/** * Disposes all objects this <code>WorkspaceInfo</code> is holding. */ final void dispose() { try { initLock.writeLock().acquire(); } catch (InterruptedException e) { throw new IllegalStateException("Unable to aquire write lock."); } try { if (!initialized) { // nothing to dispose of, we're already done return; } log.info("shutting down workspace '" + getName() + "'..."); doDispose(); // reset idle timestamp idleTimestamp = 0; active = false; initialized = false; log.info("workspace '" + getName() + "' has been shutdown"); } finally { initLock.writeLock().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 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; }
/** * 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) { } }
/** * Removes a value from the data file with the given key. * * @param key the key object */ public void remove(Object key) { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doRemove(key); m_sizeInstrument.setValue( doGetSize() ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }
/** * Store the given object in the indexed data file. * * @param key the key object * @param value the value object * @exception IOException */ public void store(Object key, Object value) throws IOException { Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doStore(key, value); m_sizeInstrument.setValue( doGetSize() ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }
Sync signal; Sync exclusive = writerStateRWLock.writeLock(); exclusive.acquire(); Object currentId = getCurrentThreadId();
Sync signal; Sync exclusive = writerStateRWLock.writeLock(); exclusive.acquire(); Object currentId = getCurrentThreadId();
/** * Clear the Store of all elements */ public void clear() { if (getLogger().isDebugEnabled()) { getLogger().debug("clear(): Clearing the database "); } Sync sync = this.lock.writeLock(); try { sync.acquire(); try { this.doClear(); m_sizeInstrument.setValue( 0 ); } finally { sync.release(); } } catch (InterruptedException ignore) { } }