public void releaseSharedLock(final int value) { final int index = index(value); if (useSpinLock) { OReadersWriterSpinLock spinLock = spinLocks[index]; spinLock.releaseReadLock(); return; } final ReadWriteLock rwLock = locks[index]; rwLock.readLock().unlock(); }
public void releaseSharedLock(final long value) { final int hashCode = longHashCode(value); final int index = index(hashCode); if (useSpinLock) { final OReadersWriterSpinLock spinLock = spinLocks[index]; spinLock.releaseReadLock(); return; } final ReadWriteLock rwLock = locks[index]; final Lock lock = rwLock.readLock(); lock.unlock(); }
public void releaseSharedLock(final T value) { final int index; if (value == null) index = 0; else index = index(value.hashCode()); if (useSpinLock) { OReadersWriterSpinLock spinLock = spinLocks[index]; spinLock.releaseReadLock(); return; } final ReadWriteLock rwLock = locks[index]; final Lock lock = rwLock.readLock(); lock.unlock(); }
@Override public void unlock() { if (readLock) spinLock.releaseReadLock(); else spinLock.releaseWriteLock(); }