Question about blocking queues and continuations
Alan Bateman
Alan.Bateman at oracle.com
Wed Jul 29 09:03:28 UTC 2020
On 29/07/2020 09:04, oliver at objectscape.org wrote:
> :
>
> Problem is now that the Java scheduler that schedules virtual threads in
> Loom has no access to queueTwo as LinkedBlockingQueue is a class in the
> class library. LinkedBlockingQueue is not a language built-in type as
> channels in Go. So the Loom Java scheduler has no way to ask queueTwo
> whether it is empty and therefore there is also no possibility to
> withdraw the virtual thread from line 2 and assign it to some other
> blocking channel as in Go.
If a virtual thread blocks in LBQ::take then the virtual thread will be
parked and the underlying carrier thread will be released to do other
work. If someone else puts/offers an element into the queue then it will
unpark the blocked virtual thread, which just queues the thread to the
scheduler so it can continue execution. So conceptually similar to
goroutines but doesn't need to have support in the Java language.
> :
>
>
> My other question whether some decision has been made on this whether
> ContinuationScope and Continuation will be inaccessible for the user or
> not.
There isn't any current plan to expose an API for the underlying
continuations implementation. Yes, it is exposed in the current
prototype but some point it will move into a jdk.internal package.
-Alan.
More information about the loom-dev
mailing list