Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions streams-tests/shared/src/test/scala/zio/stream/ZStreamSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3725,6 +3725,17 @@ object ZStreamSpec extends ZIOBaseSpec {
_ <- stream.tapSink(sink).take(3).runDrain
result <- ref.get
} yield assertTrue(result == 6)
},
test("slow sink") {
for {
ref <- Ref.make(0)
stream = ZStream(1, 2, 3, 4, 5).rechunk(1).forever
sink = ZSink.foreach((n: Int) => ZIO.sleep(2.second) *> ref.update(_ + n))
fib <- stream.tapSink(sink).take(1).mapZIO(a => ZIO.sleep(1.second) *> ZIO.succeed(a)).runCollect.fork
_ <- TestClock.adjust(3.seconds)
res <- fib.join
result <- ref.get
} yield assert(result)(equalTo(1)) && assert(res)(equalTo(Chunk(1)))
}
),
suite("throttleEnforce")(
Expand Down
2 changes: 1 addition & 1 deletion streams/shared/src/main/scala/zio/stream/ZChannel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ sealed trait ZChannel[-Env, -InErr, -InElem, -InDone, +OutErr, +OutElem, +OutDon
}

ZChannel
.fromZIO(pullL.forkIn(scope).zipWith(pullR.forkIn(scope))(BothRunning(_, _): MergeState))
.fromZIO(pullL.forkDaemon.zipWith(pullR.forkDaemon)(BothRunning(_, _): MergeState))
.flatMap(go)
.embedInput(input)
}
Expand Down