Package net.bytebuddy.agent.builder
Class AgentBuilder.CircularityLock.Default
java.lang.Object
net.bytebuddy.agent.builder.AgentBuilder.CircularityLock.WithInnerClassLoadingLock
net.bytebuddy.agent.builder.AgentBuilder.CircularityLock.Default
- All Implemented Interfaces:
AgentBuilder.CircularityLock
- Enclosing interface:
AgentBuilder.CircularityLock
public static class AgentBuilder.CircularityLock.Default
extends AgentBuilder.CircularityLock.WithInnerClassLoadingLock
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 class net.bytebuddy.agent.builder.AgentBuilder.CircularityLock.WithInnerClassLoadingLock
AgentBuilder.CircularityLock.WithInnerClassLoadingLock.TrivialLock
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.CircularityLock
AgentBuilder.CircularityLock.Default, AgentBuilder.CircularityLock.Global, AgentBuilder.CircularityLock.Inactive, AgentBuilder.CircularityLock.WithInnerClassLoadingLock
-
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.Fields inherited from class net.bytebuddy.agent.builder.AgentBuilder.CircularityLock.WithInnerClassLoadingLock
DEFAULT_SIZE
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class net.bytebuddy.agent.builder.AgentBuilder.CircularityLock.WithInnerClassLoadingLock
acquire
-
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()Creates a default lock with a default size for the amount of global locks. -
Default
public Default(int size) Creates a default lock with the supplied number of global locks.- Parameters:
size
- The amount of locks used in parallel or0
if no global locks should be used.
-
-
Method Details
-
doAcquire
protected boolean doAcquire()Description copied from class:AgentBuilder.CircularityLock.WithInnerClassLoadingLock
Acquires the actual lock for the current thread.- Specified by:
doAcquire
in classAgentBuilder.CircularityLock.WithInnerClassLoadingLock
- 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. -
isLocked
protected boolean isLocked()Returnstrue
if the current thread is currently locked.- Returns:
true
if the current thread is currently locked.
-