Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use parasitic context by default in Classic pipe pattern #31917

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

leviramsey
Copy link
Contributor

Inspired by a side discussion in #31906, makes the default ExecutionContext for the Classic pipe pattern for Scala futures the parasitic (aka "same thread") context.

The Typed context.pipeToSelf counterpart only uses the parasitic context (the Classic pipe pattern is still required for piping a future to an actor that's not self). For Java futures, the ExecutionContext setting has no effect, but the use of whenComplete in both Classic and Typed has effectively the same semantics.

A local run of MiMa reported no binary issues (a little surprisingly...). Since existing source code is putting a context in the implicit scope (most likely the context/system dispatcher), new/edited code is required in order to take advantage of this, but this does remove a reason to have an implicit ExecutionContext in an actor.

@He-Pin
Copy link
Member

He-Pin commented Apr 21, 2023

I was wondering if it was because a BlockingQueue may be used for a mailbox?

@patriknw
Copy link
Member

I was wondering if it was because a BlockingQueue may be used for a mailbox?

That can be the original reason. I don't think we should risk introducing any problem by changing this.

@leviramsey
Copy link
Contributor Author

If BlockingQueue is the reason, then that would argue for using whenCompleteAsync on the CompletionStage variant (at least if the EC is an ExecutionContextExecutor), would it not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants