Class KeyedLockMap<K>

java.lang.Object
com.cryptomorin.xseries.profiles.lock.KeyedLockMap<K>
Type Parameters:
K - the type of object used to identify what the locks are associated to.

@Internal public final class KeyedLockMap<K> extends Object
A registry that queues locks per-object using KeyedLock.
  • Constructor Details

    • KeyedLockMap

      public KeyedLockMap()
  • Method Details

    • lock

      public <V> KeyedLock<K,V> lock(K key, Supplier<V> fetcher)
      See Also:
    • lock

      public <V> KeyedLock<K,V> lock(K key, Function<K,V> fetcher)
      This method will return a finalized lock if the fetcher already has the value, which prevents the unnecessary synchronization and creation of locks, otherwise the associated key will be locked and the value can be retrieved again with KeyedLock.getOrRetryValue() after the lock was released by other threads.
    • toString

      public String toString()
      Overrides:
      toString in class Object