Example usage for com.google.common.util.concurrent Striped get

List of usage examples for com.google.common.util.concurrent Striped get

Introduction

In this page you can find the example usage for com.google.common.util.concurrent Striped get.

Prototype

public abstract L get(Object key);

Source Link

Document

Returns the stripe that corresponds to the passed key.

Usage

From source file:pgentity.pool.LockManager.java

public void release(Striped<Lock> locks, List<K> keys) {
    LockCollection lockCollection = lockCollections.get();
    if (lockCollection != null) {
        for (K key : keys) {
            Lock lock = locks.get(key);
            lockCollection.release(lock);
        }/*from   w w w  .  ja v  a 2s  . c o m*/
    }
}

From source file:pgentity.pool.BlockingCache.java

private void threadReleaseResource(K key, Striped<Lock> stripedLocks) {
    LockCollection threadHold = resourceMapper.get();
    if (threadHold != null) {
        Lock lock = stripedLocks.get(key);
        threadHold.release(lock);//w  ww. ja va 2 s.c  om
    }
}

From source file:pgentity.pool.LockManager.java

public void hold(Striped<Lock> locks, List<K> keys) {
    LockCollection lockCollection = this.lockCollections.get();
    if (lockCollection == null) {
        lockCollection = new LockCollection();
        this.lockCollections.set(lockCollection);
    }/*from   ww  w .j  a v a 2s. com*/

    for (K key : keys) {
        Lock lock = locks.get(key);
        lockCollection.add(lock);
    }
}

From source file:pgentity.pool.BlockingCache.java

private void threadReleaseResources(List<K> keys, Striped<Lock> stripedLocks) {
    LockCollection threadHold = resourceMapper.get();
    if (threadHold != null) {
        for (K key : keys) {
            Lock lock = stripedLocks.get(key);
            threadHold.release(lock);//from   w  w w .  j a  v a2 s .  c om
        }
    }
}

From source file:pgentity.pool.BlockingCache.java

/**
 * Thread-safe by ThreadLocal/*from w  w  w . j a v  a  2  s  . c o  m*/
 * @param resource
 * @param lock 
 */
private void threadHoldResource(K key, Striped<Lock> stripedLocks) {
    LockCollection threadHold = resourceMapper.get();
    if (threadHold == null) {
        threadHold = new LockCollection();
        resourceMapper.set(threadHold);
    }

    Lock lock = stripedLocks.get(key);
    threadHold.add(lock);
}

From source file:pgentity.pool.BlockingCache.java

/**
 * Thread-safe by ThreadLocal/*from   w  ww . ja  va2  s. co m*/
 * @param resource
 * @param lock 
 */
private void threadHoldResources(List<K> keys, Striped<Lock> stripedLocks) {
    LockCollection threadHold = resourceMapper.get();
    if (threadHold == null) {
        threadHold = new LockCollection();
        resourceMapper.set(threadHold);
    }

    for (K key : keys) {
        Lock lock = stripedLocks.get(key);
        threadHold.add(lock);
    }
}