Skip to content

Commit

Permalink
Update fiber.md (zio#6488)
Browse files Browse the repository at this point in the history
Fix description to match code example.
  • Loading branch information
scottjad authored Apr 21, 2022
1 parent 20a8d73 commit aa89e24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/datatypes/fiber/fiber.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ A more powerful variant of `fork`, called `fork0`, allows specification of super

The `ZIO#forkDaemon` forks the effect into a new fiber **attached to the global scope**. Because the new fiber is attached to the global scope, when the fiber executing the returned effect terminates, the forked fiber will continue running.

In the following example, we have three effects: `inner`, `outer`, and `mainApp`. The outer effect is forking the `inner` effect using `ZIO#forkDaemon`. The `mainApp` effect is forking the `inner` fiber using `ZIO#fork` method and interrupt it after 3 seconds. Since the `inner` effect is forked in global scope, it will not be interrupted and continue its job:
In the following example, we have three effects: `inner`, `outer`, and `mainApp`. The outer effect is forking the `inner` effect using `ZIO#forkDaemon`. The `mainApp` effect is forking the `outer` fiber using `ZIO#fork` method and interrupt it after 3 seconds. Since the `inner` effect is forked in global scope, it will not be interrupted and continue its job:

```scala mdoc:silent:nest
val inner = putStrLn("Inner job is running.")
Expand All @@ -78,7 +78,7 @@ val outer = (
} yield ()
).onInterrupt(putStrLn("Outer job interrupted.").orDie)

val myApp = for {
val mainApp = for {
fiber <- outer.fork
_ <- fiber.interrupt.delay(3.seconds)
_ <- ZIO.never
Expand Down

0 comments on commit aa89e24

Please sign in to comment.