ZIO contains a small number of data types that can help you solve complex problems in asynchronous and concurrent programming.
- Fiber — A fiber value models an
IOvalue that has started running, and is the moral equivalent of a green thread.
- FiberLocal — A
FiberLocalis a variable whose value depends on the fiber that accesses it, and is the moral equivalent of Java's
- ZIO — A
ZIOis a value that models an effectful program, which might fail or succeed.
- Managed — A
Managedis a value that describes a perishable resource that may be consumed only once inside a given scope.
- Promise — A
Promiseis a model of a variable that may be set a single time, and awaited on by many fibers.
- Queue — A
Queueis an asynchronous queue that never blocks, which is safe for multiple concurrent producers and consumers.
- Ref —
Ref[A]models a mutable reference to a value of type
A. The two basic operations are
set, which fills the
Refwith a new value, and
get, which retrieves its current content. All operations on a
Refare atomic and thread-safe, providing a reliable foundation for synchronizing concurrent programs.
- FiberRef —
FiberRef[A]models a mutable reference to a value of type
A. As opposed to
Ref[A], a value is bound to an executing
Fiberonly. You can think of it as Java's
- Schedule — A
Scheduleis a model of a recurring schedule, which can be used for repeating successful
IOvalues, or retrying failed
- Semaphore — A
Semaphoreis an asynchronous (non-blocking) semaphore that plays well with ZIO's interruption.
Besides the core datatypes, the following datatypes can be found in ZIO streams library:
- Sink — A
Sinkis a consumer of values from a
Stream, which may produces a value when it has consumed enough.
- Stream — A
Streamis a lazy, concurrent, asynchronous source of values.
To learn more about these data types, please explore the pages above, or check out the Scaladoc documentation.