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

Add VertxContextSupport#executeBlocking() #43444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkouba
Copy link
Contributor

@mkouba mkouba commented Sep 23, 2024

  • to improve WS next UX; i.e to run blocking code in HttpUpgradeCheck#perform() easily

- to improve WS next UX; i.e to run blocking code in
HttpUpgradeCheck#perform() easily
@mkouba mkouba force-pushed the ws-next-blocking-http-upgrade-check branch from 9b67cbd to d211835 Compare September 23, 2024 13:39
*/
public static <T> Uni<T> executeBlocking(Callable<T> callable) {
Context context = getContext(true);
return Uni.createFrom().completionStage(() -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer might be slightly better.

@jponge wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer might be slightly better.

In what exactly? I mean, both suppliers are called at subscription time. And we would need to convert the io.vertx.core.Future to the Uni anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to https://javadoc.io/doc/io.smallrye.reactive/mutiny/latest/io.smallrye.mutiny/io/smallrye/mutiny/groups/UniCreate.html which avoid using completion stages and it's slightly more optimized. But, yes, then you need an emitter, so the cost would be almost equivalent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry, missed the anchor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred with supplier is better, but a CompletionStage isn't incorrect per-se.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred with supplier is better, but a CompletionStage isn't incorrect per-se.

Better in terms of performance, or?

Hm, but how do I create a Uni from io.vertx.core.Future without Uni.createFrom().completionStage()? That's what io.smallrye.mutiny.vertx.UniHelper.toUni(Future<T>) does by the way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes yes you are right

@mkouba mkouba marked this pull request as ready for review September 24, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants