Package boofcv.misc
Class VariableLockSet
java.lang.Object
boofcv.misc.VariableLockSet
public class VariableLockSet extends Object
Base class for a set of variables which are all controlled by a single lock
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
VariableLockSet.SelectObject<T>
static interface
VariableLockSet.SelectObjectNull<T>
static class
VariableLockSet.SelectResults<T>
-
Field Summary
Fields Modifier and Type Field Description protected ReentrantLock
lock
-
Constructor Summary
Constructors Constructor Description VariableLockSet()
-
Method Summary
Modifier and Type Method Description boolean
isLocked()
Returns true if the lock is activevoid
lock()
boolean
safe(long timeoutMS, Runnable r)
Safe but with a timeout for aquiring the lockvoid
safe(Runnable r)
<T> VariableLockSet.SelectResults<T>
select(long timeoutMS, VariableLockSet.SelectObject<T> select)
Selects an object with a timeout for acquiring the lock.<T> T
select(VariableLockSet.SelectObject<T> select)
<T> @Nullable VariableLockSet.SelectResults<T>
selectNull(long timeoutMS, VariableLockSet.SelectObjectNull<T> select)
Selects an object with a timeout for acquiring the lock.<T> T
selectNull(VariableLockSet.SelectObjectNull<T> select)
void
unlock()
-
Field Details
-
lock
-
-
Constructor Details
-
VariableLockSet
public VariableLockSet()
-
-
Method Details
-
safe
-
select
-
safe
Safe but with a timeout for aquiring the lock -
select
public <T> VariableLockSet.SelectResults<T> select(long timeoutMS, VariableLockSet.SelectObject<T> select)Selects an object with a timeout for acquiring the lock.- Parameters:
timeoutMS
- How long it will wait to get the lock in millisecondsselect
- Function used to select object- Returns:
- Results which indicate of the lock was acquired and the found object
-
selectNull
-
selectNull
@Nullable public <T> @Nullable VariableLockSet.SelectResults<T> selectNull(long timeoutMS, VariableLockSet.SelectObjectNull<T> select)Selects an object with a timeout for acquiring the lock.- Parameters:
timeoutMS
- How long it will wait to get the lock in millisecondsselect
- Function used to select object- Returns:
- Results which indicate of the lock was acquired and the found object
-
lock
public void lock() -
unlock
public void unlock() -
isLocked
public boolean isLocked()Returns true if the lock is active
-