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); } }
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); } }