Class CompositeLock

  • All Implemented Interfaces:
    java.lang.AutoCloseable, ResourceLock

    class CompositeLock
    extends java.lang.Object
    implements ResourceLock
    Since:
    1.3
    • Field Detail

      • locks

        private final java.util.List<java.util.concurrent.locks.Lock> locks
      • exclusive

        private final boolean exclusive
    • Constructor Detail

      • CompositeLock

        CompositeLock​(java.util.List<ExclusiveResource> resources,
                      java.util.List<java.util.concurrent.locks.Lock> locks)
    • Method Detail

      • getLocks

        java.util.List<java.util.concurrent.locks.Lock> getLocks()
      • acquire

        public ResourceLock acquire()
                             throws java.lang.InterruptedException
        Description copied from interface: ResourceLock
        Acquire this resource lock, potentially blocking.
        Specified by:
        acquire in interface ResourceLock
        Returns:
        this lock so it can easily be used in a try-with-resources statement.
        Throws:
        java.lang.InterruptedException - if the calling thread is interrupted while waiting to acquire this lock
      • acquireAllLocks

        private void acquireAllLocks()
                              throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • release

        public void release()
        Description copied from interface: ResourceLock
        Release this resource lock.
        Specified by:
        release in interface ResourceLock
      • release

        private void release​(java.util.List<java.util.concurrent.locks.Lock> acquiredLocks)
      • isExclusive

        public boolean isExclusive()
        Description copied from interface: ResourceLock
        {@return whether this lock requires exclusiveness}
        Specified by:
        isExclusive in interface ResourceLock
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object