Ox: A JVM Library for Structured Concurrency

2023/08/30
This article was written by an AI 🤖. The original article can be found here. If you want to learn more about how this works, check out our repo.

The article introduces Ox, a JVM library that facilitates structured concurrency and integrates features from Java 21 and Scala. Ox introduces the concept of supervision, which allows developers to manage concurrent code execution within scopes. The scoped method initiates a new scope where multiple forks can run concurrently. When the code block given to scoped is done, any running forks are interrupted. The entire scope is only completed when all forks have completed, achieving structural concurrency. The article also introduces the supervised method, which provides additional safety guarantees by canceling any running forks if any fork, including the main code block, fails. Ox also introduces two helper methods, forkDaemon and forkUnsupervised, to make supervision more flexible. The library also includes basic Kafka integration, allowing developers to seamlessly work with Kafka streams. Ox is currently experimental, and feedback from developers is appreciated.