Package com.uber.cadence.workflow
Class WorkflowLocal<T>
- java.lang.Object
-
- com.uber.cadence.workflow.WorkflowLocal<T>
-
public final class WorkflowLocal<T> extends java.lang.Object
A value that is local to a single workflow execution. So it can act as a global variable for the workflow code. For example theWorkflow.isSignaled()
static method returns the correct value even if there are multiple workflows executing on the same machine simultaneously. It would be invalid if thesignaled
was astatic boolean
variable.public class Workflow { private static final WorkflowLocal<Boolean> signaled = WorkflowLocal.withInitial(() -> false); public static boolean isSignaled() { return signaled.get(); } public void signal() { signaled.set(true); } }
-
-
Constructor Summary
Constructors Constructor Description WorkflowLocal()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
void
set(T value)
static <S> WorkflowLocal<S>
withInitial(java.util.function.Supplier<? extends S> supplier)
-
-
-
Method Detail
-
withInitial
public static <S> WorkflowLocal<S> withInitial(java.util.function.Supplier<? extends S> supplier)
-
get
public T get()
-
set
public void set(T value)
-
-