on master help sign in
move sendStopToProducer inside fromProducer
9465fc0Harendra Kumar
src/Streamly/Internal/Data/Stream/Parallel.hs+1−11
@@ -334,17 +334,7 @@ newFoldSVar stt f = do
334 -- Add the producer thread-id to the SVar.
334 -- Add the producer thread-id to the SVar.
335 liftIO myThreadId >>= modifyThread sv
335 liftIO myThreadId >>= modifyThread sv
336
336
337− -- XXX move this in fromProducer itself.
338− --
339− -- A wrapper to send a Stop event back to the producer when the fold
340− -- receives a stop from the producer.
341− let pull m = mkStream $ \st yld _ stp -> do
342− let stop = sendStopToProducer sv >> stp
343− single a = yld a (K.nilM (sendStopToProducer sv))
344− yieldk a r = yld a (pull r)
345− in foldStreamShared st yieldk single stop m
346−
347− void $ doFork (void $ f $ fromStream $ pull $ fromProducer sv)
337+ void $ doFork (void $ f $ fromStream $ fromProducer sv)
348 (svarMrun sv)
338 (svarMrun sv)
349 (handleFoldException sv)
339 (handleFoldException sv)
350 return sv
340 return sv
src/Streamly/Internal/Data/Stream/SVar.hs+1
@@ -133,6 +133,7 @@ fromProducer sv = mkStream $ \st yld sng stp -> do
133 t <- liftIO $ getTime Monotonic
133 t <- liftIO $ getTime Monotonic
134 liftIO $ writeIORef (svarStopTime (svarStats sv)) (Just t)
134 liftIO $ writeIORef (svarStopTime (svarStats sv)) (Just t)
135 liftIO $ printSVar sv "SVar Done"
135 liftIO $ printSVar sv "SVar Done"
136+ sendStopToProducer sv
136 stp
137 stp
137
138
138 {-# INLINE processEvents #-}
139 {-# INLINE processEvents #-}