[External] : Re: Future.resultNow / exceptionNow

Remi Forax forax at univ-mlv.fr
Sun Nov 21 15:47:20 UTC 2021


----- Original Message -----
> From: "Ron Pressler" <ron.pressler at oracle.com>
> To: "Alex Otenko" <oleksandr.otenko at gmail.com>
> Cc: "loom-dev" <loom-dev at openjdk.java.net>
> Sent: Dimanche 21 Novembre 2021 16:01:43
> Subject: Re: [External] : Re: Future.resultNow / exceptionNow


[...]

>> 
>> — Ron
> 
> 
> P.S.
> 
> I expect that in the future we’ll be able to offer a nicer way of polling that
> combines the call to state and xxxNow with deconstructing patterns, i.e.:
> 
> switch(f) {
>    case result(String x) -> …
>    case error(Throwable t) -> …
>    case cancelled -> …
>    case running -> …
> }

given that a Future is mutable it's more something like

switch(f.stateInfo()) {
   case result(String x) -> …
   case error(Throwable t) -> …
   case cancelled -> …
   case running -> …
}

Rémi


More information about the loom-dev mailing list