Class WorkflowThreadLocal<T>
java.lang.Object
io.temporal.workflow.WorkflowThreadLocal<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()voidstatic <S> WorkflowThreadLocal<S> withCachedInitial(Supplier<? extends S> supplier) Create an instance that returns the value returned by the givenSupplierwhenset(Object)has not yet been called in the Workflow, and then stores the returned value inside theWorkflowThreadLocal.static <S> WorkflowThreadLocal<S> withInitial(Supplier<? extends S> supplier) Deprecated.
-
Constructor Details
-
WorkflowThreadLocal
public WorkflowThreadLocal()
-
-
Method Details
-
withInitial
Deprecated.Because the non-caching behavior of this API is typically not desirable, it's recommend to usewithCachedInitial(Supplier)instead.Create an instance that returns the value returned by the givenSupplierwhenset(Object)has not yet been called in the thread. Note that the value returned by theSupplieris not stored in theWorkflowThreadLocalimplicitly; repeatedly callingget()will always re-execute theSupplieruntil you callset(Object)for the first time. This differs from the behavior ofThreadLocal. If you want the value returned by theSupplierto be stored in theWorkflowThreadLocal, which matches the behavior ofThreadLocal, usewithCachedInitial(Supplier)instead.- Type Parameters:
S- The type stored in theWorkflowThreadLocal.- Parameters:
supplier- Callback that will be executed wheneverget()is called, untilset(Object)is called for the first time.- Returns:
- A
WorkflowThreadLocalinstance.
-
withCachedInitial
Create an instance that returns the value returned by the givenSupplierwhenset(Object)has not yet been called in the Workflow, and then stores the returned value inside theWorkflowThreadLocal.- Type Parameters:
S- The type stored in theWorkflowThreadLocal.- Parameters:
supplier- Callback that will be executed whenget()is called for the first time, ifset(Object)has not already been called.- Returns:
- A
WorkflowThreadLocalinstance.
-
get
-
set
-
withCachedInitial(Supplier)instead.