ZIO is a highly concurrent framework powered by fibers that are lightweight virtual threads. They also enable tremendous scalability compared to threads.
2. Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to
the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
3. Our Agenda
01 Introduction to ZIO Fibers
02 How ZIO Fibers are different from Threads
03 Key features of ZIO Fibers
04 Operations on ZIO Fibers
05 Demo
5. Introduction to ZIO Fibers
Fiber are lightweight equivalents of operating system threads.
Similarly like a thread, a fiber models a running computation and
instructions on a single fiber are executed sequentially.
ZIO is a highly concurrent framework, powered by fibers. This
powerful concurrency model helps us in achieving
highly-scalable, ultra low-latency applications that are globally
efficient and resource-safe.
7. ZIO Fibers compared to Threads
Similarities
ZIO fibers, just like operating system-level threads, have a well-defined lifespan that is dictated by
the effect they are executing. Fibers also contain distinct identities, stacks (including stack traces),
local state, and status (such as done, running, or suspended). Every fiber either fails or succeeds
depending on whether the effect it is executing succeeds or fails.
Differences
● Threads are scarce
● Expensive on creation
● Much Overhead on Context Switching
● Lack of Composability
11. Basic Operations on ZIO Fibers
Forking Effects
The most fundamental way of creating a fiber is to take an existing effect and fork it. Conceptually,
forking an effect begins executing the effect on a new fiber, giving you a reference to the newly-created
fiber. Thus whenever we need to start a fiber, we have to fork an effect to get a new fiber.
Joining Fibers
Joining is a way of waiting for that fiber to compute its value. We are going to wait until it's done and
receive its result. The effect returned by fiber.join will succeed or fail as per the fiber.
12. Basic Operations on ZIO Fibers
Awaiting Fibers
To inspect whether our fiber succeeded or failed, we can call await on that fiber. This call will wait for
that fiber to terminate, and it will give us back the fiber's value as an Exit. That exit value could be failure
or success.
Interrupting Fibers
A fiber whose result is no longer needed may be interrupted, which immediately terminates the fiber. The
interrupt operation does not resume until the fiber has completed or has been interrupted and all its
finalizers have been run.