com.espertech.esper.epl.table.mgmt.TableExprEvaluatorContext Maven / Gradle / Ivy
/*
***************************************************************************************
* Copyright (C) 2006 EsperTech, Inc. All rights reserved. *
* http://www.espertech.com/esper *
* http://www.espertech.com *
* ---------------------------------------------------------------------------------- *
* The software in this package is published under the terms of the GPL license *
* a copy of which has been included with this distribution in the license.txt file. *
***************************************************************************************
*/
package com.espertech.esper.epl.table.mgmt;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.locks.Lock;
public class TableExprEvaluatorContext {
private final ThreadLocal> threadLocal = new ThreadLocal>() {
protected synchronized Set initialValue() {
return new HashSet();
}
};
public boolean addAcquiredLock(Lock lock) {
return threadLocal.get().add(lock);
}
public void releaseAcquiredLocks() {
Set locks = threadLocal.get();
if (locks.isEmpty()) {
return;
}
for (Lock lock : locks) {
lock.unlock();
}
locks.clear();
}
public int getLockHeldCount() {
return threadLocal.get().size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy