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.
  • Field Details

    • threads

      private final ConcurrentMap<Thread,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.
  • Constructor Details

    • Default

      public Default()
  • Method Details

    • acquire

      public boolean acquire()
      Attempts to acquire a circularity lock.
      Specified by:
      acquire in interface AgentBuilder.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 interface AgentBuilder.CircularityLock
    • isLocked

      protected boolean isLocked()
      Returns true if the current thread is currently locked.
      Returns:
      true if the current thread is currently locked.