Package net.bytebuddy.agent.builder
Class AgentBuilder.CircularityLock.Default
- java.lang.Object
-
- net.bytebuddy.agent.builder.AgentBuilder.CircularityLock.Default
-
- All Implemented Interfaces:
AgentBuilder.CircularityLock
- Enclosing interface:
- AgentBuilder.CircularityLock
public static class AgentBuilder.CircularityLock.Default extends java.lang.Object implements AgentBuilder.CircularityLock
A default implementation of a circularity lock. Since class loading already synchronizes on a class loader, it suffices to apply a thread-local lock.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.CircularityLock
AgentBuilder.CircularityLock.Default, AgentBuilder.CircularityLock.Global, AgentBuilder.CircularityLock.Inactive
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentMap<java.lang.Thread,java.lang.Boolean>threadsA map of threads to an unused boolean to emulate a thread-local state without using thread locals.
-
Constructor Summary
Constructors Constructor Description Default()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquire()Attempts to acquire a circularity lock.protected booleanisLocked()Returnstrueif the current thread is currently locked.voidrelease()Releases the circularity lock if it is currently acquired.
-
-
-
Field Detail
-
threads
private final java.util.concurrent.ConcurrentMap<java.lang.Thread,java.lang.Boolean> threads
A map of threads to an unused boolean to emulate a thread-local state without using thread locals. This avoids using thread-local maps and does not interfere with Java fibers in case that an instrumentation is executed from a virtual thread where thread locals are not permitted.
-
-
Method Detail
-
acquire
public boolean acquire()
Attempts to acquire a circularity lock.- Specified by:
acquirein interfaceAgentBuilder.CircularityLock- Returns:
trueif the lock was acquired successfully,falseif it is already hold.
-
release
public void release()
Releases the circularity lock if it is currently acquired.- Specified by:
releasein interfaceAgentBuilder.CircularityLock
-
isLocked
protected boolean isLocked()
Returnstrueif the current thread is currently locked.- Returns:
trueif the current thread is currently locked.
-
-