com.kuka.geometry.internal
Class TreeLock

java.lang.Object
  extended by com.kuka.geometry.internal.TreeLock

public class TreeLock
extends Object

Provides convenience methods for locking tree like data structures.


Constructor Summary
TreeLock(boolean fair)
          Constructor.
 
Method Summary
 MultiLock getMultiWriteLock(TreeLock otherLockToGet)
          Obtains a write lock for this lock and another TreeLock and avoids deadlock situations.
 Lock getSafeReadLock()
          Obtains a read lock for the tree.
 Lock getSafeWriteLock()
          Obtains a write lock for the tree.
 ReentrantReadWriteLock getTreeLock()
           
 void setTreeLock(ReentrantReadWriteLock lock)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeLock

public TreeLock(boolean fair)
Constructor.

Parameters:
fair - true if the lock initially used with this tree lock should use a fair ordering
Method Detail

getTreeLock

public ReentrantReadWriteLock getTreeLock()
Returns:
the ReentrantReadWriteLock used internally

setTreeLock

public void setTreeLock(ReentrantReadWriteLock lock)
Parameters:
lock - the new lock to be set

getSafeWriteLock

public Lock getSafeWriteLock()
Obtains a write lock for the tree. By attaching the object to another root object with another tree lock while waiting for the lock, the lock object might change. After obtaining the lock, this method checks that this did not happen and the correct lock was obtained.

Returns:
the lock that was acquired

getSafeReadLock

public Lock getSafeReadLock()
Obtains a read lock for the tree. By attaching the object to another root object with another tree lock while waiting for the lock, the lock object might change. After obtaining the lock, this method checks that this did not happen and the correct lock was obtained.

Returns:
Lock the lock that was acquired

getMultiWriteLock

public MultiLock getMultiWriteLock(TreeLock otherLockToGet)
Obtains a write lock for this lock and another TreeLock and avoids deadlock situations.

Parameters:
otherLockToGet - the other lock to obtain
Returns:
the obtained MultiLock


Copyright © 2019. All rights reserved.