News for hackers. Stuff that matters.
Re:Async file IO in Java is not truly async [Resource, Tech ... by twic on Monday January 08, 2024 @04:20PM (#38918306)
Loom goes in the opposite direction: it presents a programming model where everything is blocking all the time, then makes threads lightweight, so that's scalable. It doesn't do anything to make file operations truly async; it makes it unnecessary for them to be async.
Re:Async file IO in Java is not truly async [Resource, Tech ... by jayd16 on Monday January 08, 2024 @05:37PM (#38919315)
> it unnecessary for them to be async.

Is this true? Wouldn't they still consume an OS thread in that case; possibly consuming the pool of OS threads that are servicing the virtual threads?

How does loom handle that?

Re:Async file IO in Java is not truly async [Resource, Tech ... by adra on Monday January 08, 2024 @06:24PM (#38919936)
The JVM with virtual threads will do userspace task scheduling to take jobs on and off active OS threads. As long as Java knows he e to safely suspend the running up action, like socket.read(), the JVM could use a read selector on an off thread and something like epoll() to resume the socket and it's calling task when the blocking call is available and an OS thread capable of resuming it.
Re:Async file IO in Java is not truly async [Resource, Tech ... by gpderetta on Monday January 08, 2024 @06:11PM (#38919770)
Of course, while the user code side would look sync, the loom event scheduler would still need to implement the async file Io support.