`select` statement for Java

Remi Forax forax at univ-mlv.fr
Tue Feb 4 10:19:55 UTC 2020


----- Mail original -----
> De: "Doug Lea" <dl at cs.oswego.edu>
> À: "loom-dev" <loom-dev at openjdk.java.net>
> Envoyé: Mardi 4 Février 2020 01:32:29
> Objet: Re: `select` statement for Java

Hi Doug,

> On 2/3/20 1:38 PM, Ryan Schmitt wrote:
>> Are there any current or planned constructs in Java that allow blocking on
>> multiple streams of events simultaneously, similar to the `select`
>> statement in Go? I realize that technically speaking this is probably
>> orthogonal to Loom, but it seems like an important capability in order to
>> get the most out of the blocking, imperative thread abstraction that Loom
>> is fundamentally about.
>> 
> 
> Yes. We've been contemplating adding to java.util.concurrent a
> Loom-friendly channel-like component with select-like capabilities. I
> hope to write more about this in the coming months when it gets concrete
> enough to ask for feedback. For now: the most likely name is "Carrier",
> to distinguish from other channels and queues in Java.
> 
> As others have noted, there's not likely to be special syntax, but the
> new pattern-match constructs should serve well. As in:
> switch(selector.receive()) { case Request r -> service(r); ... }


I like the MessageBox/Mailbox metaphor given that it seems conceptually similar to Erlang.

> 
> -Doug

Rémi


More information about the loom-dev mailing list