on master help sign in
Change pollCount signature
commitcdfda9b5006ee32e4bc24c2b64c2f921ff2510e1 authorRanjeet Kumar Ranjan <ranjeetr@composewell.com> dateSat 4 Jun 2022, 18:54 (4 years ago) parent8ac1ad1
3 files changed+9−11
benchmark/Streamly/Benchmark/Prelude/Serial/Transformation.hs+2−2 core/src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+4−5 src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+3−4
benchmark/Streamly/Benchmark/Prelude/Serial/Transformation.hs+2−2
@@ -141,11 +141,11 @@ tap n = composeN n $ S.tap FL.sum
141141{-# INLINE pollCounts #-}
142142pollCounts :: Int -> SerialT IO Int -> IO ()
143143pollCounts n =
144− composeN n (Internal.pollCounts (const True) f FL.drain)
144+ composeN n (Internal.pollCounts (const True) f)
145145
146146 where
147147
148− f = Internal.rollingMap2 (-) . Internal.delayPost 1
148+ f = S.drain . Internal.rollingMap2 (-) . Internal.delayPost 1
149149
150150{-# INLINE timestamped #-}
151151timestamped :: (S.MonadAsync m) => SerialT m Int -> m ()
core/src/Streamly/Internal/Data/Stream/StreamD/Transform.hs+4−5
@@ -333,11 +333,10 @@ tapOffsetEvery offset n (Fold fstep initial extract) (Stream step state) =
333333pollCounts
334334 :: MonadAsync m
335335 => (a -> Bool)
336− -> (Stream m Int -> Stream m Int)
337− -> Fold m Int b
336+ -> (Stream m Int -> m b)
338337 -> Stream m a
339338 -> Stream m a
340−pollCounts predicate transf fld (Stream step state) = Stream step' Nothing
339+pollCounts predicate fld (Stream step state) = Stream step' Nothing
341340 where
342341
343342 {-# INLINE_LATE step' #-}
@@ -347,8 +346,8 @@ pollCounts predicate transf fld (Stream step state) = Stream step' Nothing
347346 -- However, an Int on a 32-bit machine may overflow quickly.
348347 countVar <- liftIO $ Prim.newIORef (0 :: Int)
349348 tid <- forkManaged
350− $ void $ fold fld
351− $ transf $ Prim.toStreamD countVar
349+ $ void $ fld
350+ $ Prim.toStreamD countVar
352351 return $ Skip (Just (countVar, tid, state))
353352
354353 step' gst (Just (countVar, tid, st)) = do
src/Streamly/Internal/Data/Stream/IsStream/Transform.hs+3−4
@@ -574,13 +574,12 @@ distributeAsync_ = flip (Prelude.foldr tapAsyncK)
574574pollCounts ::
575575 (IsStream t, MonadAsync m)
576576 => (a -> Bool)
577− -> (t m Int -> t m Int)
578− -> Fold m Int b
577+ -> (t m Int -> m b)
579578 -> t m a
580579 -> t m a
581−pollCounts predicate transf f xs =
580+pollCounts predicate f xs =
582581 fromStreamD
583− $ D.pollCounts predicate (toStreamD . transf . fromStreamD) f
582+ $ D.pollCounts predicate (f . fromStreamD)
584583 $ toStreamD xs
585584
586585-- | Apply a monadic function to each element flowing through the stream and