Skip to content

Commit f3186fb

Browse files
committed
fixed possible lost of event in situation many readers, few writers in unbuffered streams.
1 parent 7e28e32 commit f3186fb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

jvm/src/main/scala/gopher/impl/GuardedSPSCBufferedChannel.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ taskExecutor: ExecutorService) extends GuardedSPSCBaseChannel[F,A](gopherApi,con
8181
while(progress) {
8282
progress = false
8383
if !state.isEmpty() then
84-
val a = state.startRead()
8584
progress |= processReadsStep()
8685
else
8786
if isClosed then

jvm/src/main/scala/gopher/impl/GuardedSPSCUnbufferedChannel.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class GuardedSPSCUnbufferedChannel[F[_]:CpsAsyncMonad,A](
5454
progress = true
5555
progressWaitReader(reader)
5656
}
57+
if !writersLoopDone then
58+
// we have reader, should return one back if we want to start again
59+
// TODO: write test for this case
60+
readers.addFirst(reader)
5761
}
5862
if (isClosed && (readers.isEmpty || writers.isEmpty) ) then
5963
progress |= processWriteClose()

0 commit comments

Comments
 (0)