Example usage for com.google.common.util.concurrent CycleDetectingLockFactory newInstance

List of usage examples for com.google.common.util.concurrent CycleDetectingLockFactory newInstance

Introduction

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

Prototype

public static CycleDetectingLockFactory newInstance(Policy policy) 

Source Link

Document

Creates a new factory with the specified policy.

Usage

From source file:com.google.elysium.utils.Locks.java

public static void setPolicy(CycleDetectingLockFactory.Policy policy) {
    Locks.policy = policy;
    factory = CycleDetectingLockFactory.newInstance(policy);
}

From source file:io.tilt.minka.business.impl.SemaphoreImpl.java

public SemaphoreImpl(final Config config, final SpectatorSupplier supplier, final ShardID shardId) {
    this.config = config;
    this.rules = new HashMap<>();
    getLockingRules().forEach(rule -> this.rules.put(rule.getAction(), rule));
    this.supplier = supplier;
    locksByAction = new HashMap<>();
    final CycleDetectingLockFactory lockFactory = CycleDetectingLockFactory.newInstance(Policies.DISABLED);
    for (Action key : Action.values()) {
        ReentrantLock lock = lockFactory.newReentrantLock(key.toString());
        logger.debug("{}: ({}) Creating lock: {} for Action: {}", getClass().getSimpleName(), shardId,
                lock.getClass().getSimpleName(), key);
        locksByAction.put(key, lock);// w ww . j  a  va2s  .  co m
        //locksByAction.put(key, new ReentrantLock());
    }
}

From source file:com.google.worldcoin.utils.Threading.java

public static void setPolicy(CycleDetectingLockFactory.Policy policy) {
    Threading.policy = policy;
    factory = CycleDetectingLockFactory.newInstance(policy);
}