public final class Guard
extends java.lang.Object
Consumer or Function
objects) with read or write locks on an EventList.
These methods complement the corresponding default methods in the EventList interface.
Whereas those methods only expose EventList methods to the Consumer or Function objects, these
methods here expose the EventList implementation class and therefore offer more methods to use.
For example:
EventList<String> source = ...
TransactionList<String> transactionList = new TransactionList<>(source);
Guard.acceptWithWriteLock(transactionList, txList -> {
txList.beginEvent(true);
txList.add("A new element");
txList.set(0, "A changed element");
txList.remove(6);
txList.commitEvent();
});
| Modifier and Type | Method and Description |
|---|---|
static <E,L extends EventList<E>> |
acceptWithReadLock(L eventList,
java.util.function.Consumer<L> consumer)
Executes the block of code represented by the given consumer while holding the read lock of
the supplied
EventList. |
static <E,L extends EventList<E>> |
acceptWithWriteLock(L eventList,
java.util.function.Consumer<L> consumer)
Executes the block of code represented by the given consumer while holding the write lock of
the supplied
EventList. |
static <E,L extends EventList<E>,R> |
applyWithReadLock(L list,
java.util.function.Function<L,R> function)
Applies the given function to the supplied
EventList while holding the read lock of
this EventList. |
static <E,L extends EventList<E>,R> |
applyWithWriteLock(L list,
java.util.function.Function<L,R> function)
Applies the given function to the supplied
EventList while holding the write lock of
this EventList. |
public static <E,L extends EventList<E>> void acceptWithReadLock(L eventList, java.util.function.Consumer<L> consumer)
EventList.E - the element type of the listL - the concrete list typelist - EventListconsumer - the consumer != nullEventList.acceptWithReadLock(Consumer)public static <E,L extends EventList<E>> void acceptWithWriteLock(L eventList, java.util.function.Consumer<L> consumer)
EventList.E - the element type of the listL - the concrete list typelist - EventListconsumer - the consumer != nullEventList.acceptWithWriteLock(Consumer)public static <E,L extends EventList<E>,R> R applyWithReadLock(L list, java.util.function.Function<L,R> function)
EventList while holding the read lock of
this EventList.E - the element type of the listL - the concrete list typeR - the result type of the functionlist - EventList != nullfunction - the function != nullEventList.applyWithReadLock(Function)public static <E,L extends EventList<E>,R> R applyWithWriteLock(L list, java.util.function.Function<L,R> function)
EventList while holding the write lock of
this EventList.E - the element type of the listL - the concrete list typeR - the result type of the functionlist - EventList != nullfunction - the function != nullEventList.applyWithWriteLock(Function)Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by swimmesberger at Wed Feb 13 09:45:20 CET 2019