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 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
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap
<Thread, Boolean> A map of threads to an unused boolean to emulate a thread-local state without using thread locals. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
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.
-
-
Constructor Details
-
Default
public Default()
-
-
Method Details
-
acquire
public boolean acquire()Attempts to acquire a circularity lock.- Specified by:
acquire
in interfaceAgentBuilder.CircularityLock
- Returns:
true
if the lock was acquired successfully,false
if it is already hold.
-
release
public void release()Releases the circularity lock if it is currently acquired.- Specified by:
release
in interfaceAgentBuilder.CircularityLock
-
isLocked
protected boolean isLocked()Returnstrue
if the current thread is currently locked.- Returns:
true
if the current thread is currently locked.
-