
org.infinispan.util.concurrent.locks.OwnableReentrantLock Maven / Gradle / Ivy
package org.infinispan.util.concurrent.locks;
import net.jcip.annotations.ThreadSafe;
import org.infinispan.transaction.xa.GlobalTransaction;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.Lock;
/**
* A lock that supports reentrancy based on owner (and not on current thread). For this to work, the lock needs to be
* constructed with a reference to the {@link org.infinispan.context.InvocationContextContainer}, so it is able to
* determine whether the caller's "owner" reference is the current thread or a {@link
* org.infinispan.transaction.xa.GlobalTransaction} instance.
*
* This makes this lock implementation very closely tied to Infinispan internals, but it provides for a very clean,
* efficient and moreover familiar interface to work with, since it implements {@link java.util.concurrent.locks.Lock}.
*
* For the sake of performance, this lock only supports nonfair queueing.
*
*
* @author Manik Surtani ([email protected])
* @since 4.0
*/
@ThreadSafe
public class OwnableReentrantLock extends AbstractQueuedSynchronizer implements Lock {
private static final long serialVersionUID = 4932974734462848792L;
private transient Object owner;
private final ThreadLocal
© 2015 - 2025 Weber Informatics LLC | Privacy Policy