#1311: Start side effects DEFAULT
instead of LAZY
.
#1312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #1311 for more information on the problem.
The first commit is a red test that will test that behaviour on Android with the
Main.immediate
dispatcher.The second commit makes that test green!!
It does so by launching side effects with
DEFAULT
instead ofLAZY
. That means that with an eager dispatcher likeMain.immediate
your workers and side effects will be eagerly entered as they are created duringrender
. We want to maintain the distinction that we cannot send to the sink in render() but we need to be able to do so in a worker/side effect. So we freeze theRenderContext
whenever we dispatch the coroutine for that side effect (and then unfreeze it as necessary when that is complete) using aContinuationInterceptor
.Note that this is a pretty significant change to the contract for workers/side effects; we've explored this before without making any significant changes, preferring instead to provide the
CoroutineScope
of the Workflow with aSessionWorkflow
( #1102, #1093 ).In this instance our motivation is to enable further optimization and it is a pretty good motivation!
We will want to reflect on ramifications of this semantics change.