public class OrderedLock extends Object
Modifier and Type | Method and Description |
---|---|
static OrderedLock |
on(Collection<?> locks)
Creates an OrderedLock for the given collection of locks.
|
static OrderedLock |
on(Object... locks)
Creates an OrderedLock for the given array of locks.
|
<T> T |
takeAndGet(Supplier<T> toGet)
Takes the locks in a globally consistent order, then calls the given supplier and returns its value.
|
void |
takeAndRun(Runnable toRun)
Takes the locks in a globally consistent order, then runs the given Runnable.
|
Runnable |
wrap(Runnable toWrap)
Returns a Runnable which will get and release the appropriate locks before executing its argument.
|
<T> Supplier<T> |
wrap(Supplier<T> toWrap)
Returns a Supplier which will get and release the appropriate locks before executing its argument.
|
public static OrderedLock on(Collection<?> locks)
public static OrderedLock on(Object... locks)
public <T> T takeAndGet(Supplier<T> toGet)
public void takeAndRun(Runnable toRun)
public Runnable wrap(Runnable toWrap)