Class CloseableReentrantReadWriteLock

java.lang.Object
com.inductiveautomation.ignition.common.util.CloseableReentrantReadWriteLock

public class CloseableReentrantReadWriteLock extends Object
A wrapper around ReentrantReadWriteLock that provides auto-closeable lock acquisition for use with try-with-resources.

Example usage:


 private final CloseableLock lock = new CloseableLock(false);

 public void doSomethingUnderReadLock() {
     try (var ignored = lock.acquireReadLock()) {
         // ... code that runs while holding the read lock ...
     }
 }

 public void doSomethingUnderWriteLock() {
     try (var ignored = lock.acquireWriteLock()) {
         // ... code that runs while holding the write lock ...
     }
 }