Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by closeparen on Monday May 02, 2022 @02:14PM
(#31238715)
How does async/await mitigate #1? Interleaved execution is enough to give you data races; you don't need actual parallelism.
[ Parent
| on HN ]
Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by pron on Monday May 02, 2022 @02:16PM
(#31238744)
Yes, but it requires a special call site (transitively, all the way up the stack) that permits the interleaving, and so cannot sneak into existing code that might implicitly assume no interleaving.
Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by gpderetta on Tuesday May 03, 2022 @06:53AM
(#31246807)
but good old callback-based code still allows for interleaving and AFAIK JS doesn't require any callsite allocation for that.
Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by pron on Tuesday May 03, 2022 @06:28PM
(#31254414)
It does not allow for interleaving. Interleaving means that state can change in the same subroutine.
Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by gpderetta on Tuesday May 03, 2022 @09:47PM
(#31255883)
What I mean is that subroutine can observe its own state being changed even after a call of a non-sync marked function if that function directly or indirectly calls into a closure closing over that subroutine state.
I.e. IMHO async offers very weak reentrancy guarantees that are better enforced via other means (rust-like lifetimes, immutability annotations, atomic contructs, etc).