Package com.vaadin.signals
Class SignalEnvironment
java.lang.Object
com.vaadin.signals.SignalEnvironment
The context in which signal operations are processed. Gives frameworks
control over how application code is executed to allow acquiring relevant
locks while running callbacks or to run potentially slow operations
asynchronously without holding irrelevant locks. It is assumed that the
environment is based on a
ThreadLocal with regards to how results can
be cached between invocations.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutorQueries currently active environments for an executor to use for notifying the results of an operation that is currently submitted.static ExecutorGets an executor that queries currently active environments for an executor to use for evaluating changes for an effect.protected abstract ExecutorGets an executor to use for running the callback of an effect.protected abstract ExecutorGets an executor to use for asynchronously notifying about operation results.protected abstract booleanisActive()Checks whether this environment is active on the current thread.static Runnableregister(SignalEnvironment environment) Registers a signal environment to consider when processing signal operations.
-
Constructor Details
-
SignalEnvironment
public SignalEnvironment()Creates a new signal environment.
-
-
Method Details
-
isActive
protected abstract boolean isActive()Checks whether this environment is active on the current thread. No other instance methods will be run while the environment is not active.- Returns:
trueif this environment is active,falseif it's inactive
-
getResultNotifier
Gets an executor to use for asynchronously notifying about operation results. This method is run when an operation is submitted and the returned executor is used to notify of the results when the operation has been fully processed. The executor can thus be used to make sure the notification is delivered in the same context as where the operation was initiated. The notification is delivered immediately if no notifier is provided. It is recommended that the executor preserves ordering of submitted tasks within the same context so that notifications are delivered in the order that operations have been applied.- Returns:
- an executor to use for notifying about operation results, or
nullto notify about results immediately
-
getEffectDispatcher
Gets an executor to use for running the callback of an effect. The executor can be used to make effect callback invocations asynchronous rather than blocking the thread that applied the change until all affected effects have been processed. This executor does not need to preserve ordering since the effect callback always uses the latest signal values without concern for in which order values have been changed.- Returns:
- the executor to use for invoking affected effects, or
nullto invoke the callbacks immediately
-
register
Registers a signal environment to consider when processing signal operations. The environment should be unregistered using the returned callback when it's no longer needed.- Parameters:
environment- the environment to register, notnull- Returns:
- callback for unregistering the environment, not
null
-
getCurrentResultNotifier
Queries currently active environments for an executor to use for notifying the results of an operation that is currently submitted. An immediate executor is returned if no executor is provided by registered environments.- Returns:
- the executor to use, not
null - See Also:
-
getDefaultEffectDispatcher
Gets an executor that queries currently active environments for an executor to use for evaluating changes for an effect. An immediate executor is used if no executor is provided by registered environments.- Returns:
- the executor to use, not
null - See Also:
-