Interface AsyncRenderer
To render the component associated with the AsyncRenderer call
its render
method with the arguments used to do the rendering. Multiple calls to the
render method may overwrite each other. That is, only the last
render method call is guaranteed to have any effect previous calls
might be discarded at the discretion of the implementation. Therefore a
single instance of AsyncRenderer should not be used to render
multiple components.
A rendering request is defined by an AsyncDataLink and a
DataRenderer where the data link provides the data for the
DataRenderer. In what context the AsyncRenderer calls the
rendering methods is completely implementation dependent but usually it
should execute it in a context of a TaskExecutor.
Note however that implementations are also allowed to execute rendering
synchronously (despite the name of this class). For example, executing
synchronously might be useful for debugging.
Note on cancellation: Rendering requests can be canceled but note that canceling a request might also implicitly cause the cancellation of every previous rendering requests. This is because the canceled request might have caused the cancellation of previous requests (since rendering requests may overwrite each other).
Thread safety
Implementations of this interface are required to be safe to be accessed from multiple threads concurrently.Synchronization transparency
Implementations of this listener are not required to be synchronization transparent.-
Method Summary
Modifier and TypeMethodDescription<DataType> RenderingStaterender(CancellationToken cancelToken, AsyncDataLink<DataType> dataLink, DataRenderer<? super DataType> renderer) Submits a rendering requests to be done asynchronously.
-
Method Details
-
render
<DataType> RenderingState render(CancellationToken cancelToken, AsyncDataLink<DataType> dataLink, DataRenderer<? super DataType> renderer) Submits a rendering requests to be done asynchronously.First the
startRenderingmethod of the renderer will be called, then the data is requested from the passedAsyncDataLinkand the provided data is passed to therendermethod of the renderer. Once each data has been retrieved by the data link or this rendering request has been canceled (either by explicit cancellation or by another request overwriting it)finishRenderingwill be called. ThefinishRenderingmethod is always called if thestartRenderingmethod has been called.Note that if another
rendermethod call overwrites this request, this request might be completely ignored.- Type Parameters:
DataType- the type of the data retrieved by the passed data link- Parameters:
cancelToken- theCancellationTokenwhich can be used to cancel this rendering request. This argument cannot benull.dataLink- theAsyncDataLinkproviding the data for therendermethod of the passed renderer. This argument can benull, in which case a data link is assumed which does not return any data but completes successfully immediately.renderer- theDataRendererwhich is used to do the rendering. How and where this renderer renders depends completely on the passedDataRenderer. This argument cannot benull.- Returns:
- an object through which the caller might check the progress of
this rendering request. This method never returns
null. - Throws:
NullPointerException- thrown if the specifiedCancellationTokenor theDataRendererisnull
-