[concurrency-interest] map over j.u.c.CompletableFuture with strict threading semantics

Dimitar Georgiev dimitar.georgiev.bg at gmail.com
Fri Oct 20 10:39:06 EDT 2017


Sorry if this has already been discussed.

I need to implement the following function:

public static <A, B> CompletableFuture<B> map(CompletableFuture<A>
upstream, Function<A, B> f);

It's pretty apparent what the function does. However, it has the
requirement that f() be always executed in the thread where upstream
is completed. (That is, if upstream is completed non-exceptionally,
since if it was not, f will not be called so there is no threading
semantics concerning f)

Is this possible with j.u.c.CompletableFuture?

Regards, Dimitar


More information about the Concurrency-interest mailing list