Skip to content

Commit 8860da6

Browse files
move sendStopToProducer inside fromProducer
1 parent 902a55d commit 8860da6

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/Streamly/Internal/Data/Stream/Parallel.hs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,7 @@ newFoldSVar stt f = do
335335
-- Add the producer thread-id to the SVar.
336336
liftIO myThreadId >>= modifyThread sv
337337

338-
-- XXX move this in fromProducer itself.
339-
--
340-
-- A wrapper to send a Stop event back to the producer when the fold
341-
-- receives a stop from the producer.
342-
let pull m = mkStream $ \st yld _ stp -> do
343-
let stop = sendStopToProducer sv >> stp
344-
single a = yld a (K.nilM (sendStopToProducer sv))
345-
yieldk a r = yld a (pull r)
346-
in foldStreamShared st yieldk single stop m
347-
348-
void $ doFork (void $ f $ fromStream $ pull $ fromProducer sv)
338+
void $ doFork (void $ f $ fromStream $ fromProducer sv)
349339
(svarMrun sv)
350340
(handleFoldException sv)
351341
return sv

src/Streamly/Internal/Data/Stream/SVar.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ fromProducer sv = mkStream $ \st yld sng stp -> do
133133
t <- liftIO $ getTime Monotonic
134134
liftIO $ writeIORef (svarStopTime (svarStats sv)) (Just t)
135135
liftIO $ printSVar sv "SVar Done"
136+
sendStopToProducer sv
136137
stp
137138

138139
{-# INLINE processEvents #-}

0 commit comments

Comments
 (0)