|
|
|
|
|
by didibus
1373 days ago
|
|
The additional features of structured concurency affect the API though, because you need to introduce scopes of supervision/cancellation/retries. If any async operation fails, at what level up the waiting chain do you want to cancel all other concurent tasks under it and retry the entire async flow? So you need the APIs/syntax to have ways to define these scope of cancellation/retries. As I understand, this is why it is called "structured", it refers to similar "structured" programming that introduced lexically scope restricted procedures, conditionals and loops. Edit: Also, just want to point out that you shouldn't get mixed up between async/await and future/promise. Async/await often uses future/promise, but don't necessarily have too. But future/promise is an async API that existed before async/await, and supports threaded concurency just fine. You can use future/promise in Java with both threads or virtual threads. Using it with virtual threads won't color functions because at any time you can block on a future/promise and extract the value, so it's possible to go from a future/promise returning function to one that doesn't return a future/promise. |
|