Re: curious if there is a Local.java in the works for CompletableFutures like scala has

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: curious if there is a Local.java in the works for CompletableFutures like scala has

Viktor Klang
Ah, this question comes up once in a while, the biggest questions in my mind are:
1) It's easy to lose context when intermediate libraries/Executors get involved, how does the developer detect and fix it?
2) It's unclear what fan-in behaviors like zip, merge etc mean in terms of what the local values should be?
3) It's unclear what fan-out behaviors like split, route, broadcast mean in terms of what the local values should be?

On Mon, May 22, 2017 at 9:44 PM, Martin Buchholz <[hidden email]> wrote:
There's not likely to be any support for local context anywhere in java.util.concurrent, but it seems not too hard to roll your own support with a custom executor to be used with CompletableFuture that kept track of any local context.

On Fri, May 19, 2017 at 1:16 PM, Pavel Rappo <[hidden email]> wrote:
General questions on concurrency in Java should be asked here:

   http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest

> On 18 May 2017, at 21:57, Dean Hiller <[hidden email]> wrote:
>
> Way more detail here...
>
> http://stackoverflow.com/questions/37933713/does-completablefuture-have-a-corresponding-local-context
>
> So I was wondering if this was going to be added at some point to the jdk
> as I could not figure out how to set something so it was still available on
> the thread at a later time when traversing async thenCompose, thenAccept.
>
> thanks,
> Dean



_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest




--
Cheers,

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: curious if there is a Local.java in the works for CompletableFutures like scala has

Josh Humphries-2
Pavel,
It sounds like you want something like this and this, and specify the former as the Executor parameter to the CompletionStage chaining methods. Java 9 adds new overridable methods to CompletableFuture so that you could sub-class it and override defaultExecutor(), so the context is always correctly propagated for your sub-classed kind of future.

----
Josh Humphries
[hidden email]

On Mon, May 22, 2017 at 3:44 PM, Martin Buchholz <[hidden email]> wrote:
There's not likely to be any support for local context anywhere in java.util.concurrent, but it seems not too hard to roll your own support with a custom executor to be used with CompletableFuture that kept track of any local context.

On Fri, May 19, 2017 at 1:16 PM, Pavel Rappo <[hidden email]> wrote:
General questions on concurrency in Java should be asked here:

   http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest

> On 18 May 2017, at 21:57, Dean Hiller <[hidden email]> wrote:
>
> Way more detail here...
>
> http://stackoverflow.com/questions/37933713/does-completablefuture-have-a-corresponding-local-context
>
> So I was wondering if this was going to be added at some point to the jdk
> as I could not figure out how to set something so it was still available on
> the thread at a later time when traversing async thenCompose, thenAccept.
>
> thanks,
> Dean



_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest



_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: curious if there is a Local.java in the works for CompletableFutures like scala has

Alex Otenko
In reply to this post by Viktor Klang
Why would someone want to rely on state they cannot control?

Is the idea to subvert some API that does not provide a way to pass state? This is strange especially in the context of Scala, where you can easily form tuples.

Alex

On 22 May 2017, at 20:44, Martin Buchholz <[hidden email]> wrote:

There's not likely to be any support for local context anywhere in java.util.concurrent, but it seems not too hard to roll your own support with a custom executor to be used with CompletableFuture that kept track of any local context.

On Fri, May 19, 2017 at 1:16 PM, Pavel Rappo <[hidden email]> wrote:
General questions on concurrency in Java should be asked here:

   http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest

> On 18 May 2017, at 21:57, Dean Hiller <[hidden email]> wrote:
>
> Way more detail here...
>
> http://stackoverflow.com/questions/37933713/does-completablefuture-have-a-corresponding-local-context
>
> So I was wondering if this was going to be added at some point to the jdk
> as I could not figure out how to set something so it was still available on
> the thread at a later time when traversing async thenCompose, thenAccept.
>
> thanks,
> Dean


_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest


_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
Loading...