private <V> V doAndReleaseWriteLock(PutAction<V> putAction) { if (putAction.element == null) { return null; } Object key = putAction.element.getObjectKey(); Sync lock = getLockForKey(key); if (!lock.isHeldByCurrentThread(LockType.WRITE)) { lock.lock(LockType.WRITE); } try { return putAction.put(); } finally { //Release the writelock here. This will have been acquired in the get, where the element was null lock.unlock(LockType.WRITE); } }
public Element get(final Object key) throws RuntimeException, LockTimeoutException { getObserver.begin(); Sync lock = getLockForKey(key); acquiredLockForKey(key, lock, LockType.READ); Element element;
private <V> V doAndReleaseWriteLock(PutAction<V> putAction) { if (putAction.element == null) { return null; } Object key = putAction.element.getObjectKey(); Sync lock = getLockForKey(key); if (!lock.isHeldByCurrentThread(LockType.WRITE)) { lock.lock(LockType.WRITE); } try { return putAction.put(); } finally { //Release the writelock here. This will have been acquired in the get, where the element was null lock.unlock(LockType.WRITE); } }
private <V> V doAndReleaseWriteLock(PutAction<V> putAction) { if (putAction.element == null) { return null; } Object key = putAction.element.getObjectKey(); Sync lock = getLockForKey(key); if (!lock.isHeldByCurrentThread(LockType.WRITE)) { lock.lock(LockType.WRITE); } try { return putAction.put(); } finally { //Release the writelock here. This will have been acquired in the get, where the element was null lock.unlock(LockType.WRITE); } }
private <V> V doAndReleaseWriteLock(PutAction<V> putAction) { if (putAction.element == null) { return null; } Object key = putAction.element.getObjectKey(); Sync lock = getLockForKey(key); if (!lock.isHeldByCurrentThread(LockType.WRITE)) { lock.lock(LockType.WRITE); } try { return putAction.put(); } finally { //Release the writelock here. This will have been acquired in the get, where the element was null lock.unlock(LockType.WRITE); } }
public Element get(final Object key) throws RuntimeException, LockTimeoutException { Sync lock = getLockForKey(key); acquiredLockForKey(key, lock, LockType.READ); Element element;
public Element get(final Object key) throws RuntimeException, LockTimeoutException { getObserver.begin(); Sync lock = getLockForKey(key); acquiredLockForKey(key, lock, LockType.READ); Element element;
public Element get(final Object key) throws RuntimeException, LockTimeoutException { getObserver.begin(); Sync lock = getLockForKey(key); acquiredLockForKey(key, lock, LockType.READ); Element element;