Package net.hydromatic.morel.util
Class ThreadLocals
java.lang.Object
net.hydromatic.morel.util.ThreadLocals
Utilities for
ThreadLocal.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidlet(ThreadLocal<T> threadLocal, T value, Runnable runnable) Performs an action with a thread-local set to a particular value.static <T,R> R let(ThreadLocal<T> threadLocal, T value, Supplier<R> supplier) Performs an action with a thread-local set to a particular value, and returns the result.static <T> voidmutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Runnable runnable) Performs an action with a thread-local set to a value derived from its current value via a transformer.static <T,R> R mutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Supplier<R> supplier) Performs an action with a thread-local set to a value derived from its current value via a transformer, and returns the result.
-
Constructor Details
-
ThreadLocals
private ThreadLocals()
-
-
Method Details
-
let
Performs an action with a thread-local set to a particular value. -
let
Performs an action with a thread-local set to a particular value, and returns the result. -
mutate
public static <T> void mutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Runnable runnable) Performs an action with a thread-local set to a value derived from its current value via a transformer. -
mutate
public static <T,R> R mutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Supplier<R> supplier) Performs an action with a thread-local set to a value derived from its current value via a transformer, and returns the result.
-