-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: main
Are you sure you want to change the base?
Conversation
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
9b67cbd
to
d211835
Compare
*/ | ||
public static <T> Uni<T> executeBlocking(Callable<T> callable) { | ||
Context context = getContext(true); | ||
return Uni.createFrom().completionStage(() -> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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