@@ -3778,15 +3778,16 @@ tapOffsetEvery offset n f xs =
3778tapAsync :: (IsStream t, MonadAsync m) => FL.Fold m a b -> t m a -> t m a
3778tapAsync :: (IsStream t, MonadAsync m) => FL.Fold m a b -> t m a -> t m a
3779tapAsync f xs = D.fromStreamD $ D.tapAsync f (D.toStreamD xs)
3779tapAsync f xs = D.fromStreamD $ D.tapAsync f (D.toStreamD xs)
3781−-- | Maintain the count of elements flowing in the stream and poll the count
3781+-- | @pollCounts predicate transform fold stream@ counts those elements in the
3782−-- asynchronously from another thread. The count stream is transformed using
3782+-- stream that pass the @predicate@. The resulting count stream is sent to
3783−-- the supplied transform and then folded using the supplied fold. The thread
3783+-- another thread which transforms it using @transform@ and then folds it using
3784−-- is automatically cleaned up if the stream stops or aborts due to exception.
3784+-- @fold@. The thread is automatically cleaned up if the stream stops or
3785+-- aborts due to exception.
3786-- For example, to print the count of elements processed every second:
3787-- For example, to print the count of elements processed every second:
3789−-- > S.drain $ S.pollCounts (rollingMap (-) . delayPost 1) (FL.drainBy print)
3790+-- > S.drain $ S.pollCounts (const True) (S.rollingMap (-) . S.delayPost 1) (FL.drainBy print)
3790-- $ S.enumerateFrom 0
3791-- $ S.enumerateFrom 0
@@ -3797,13 +3798,14 @@ tapAsync f xs = D.fromStreamD $ D.tapAsync f (D.toStreamD xs)
3797{-# INLINE pollCounts #-}
3798{-# INLINE pollCounts #-}
3798pollCounts ::
3799pollCounts ::
3799 (IsStream t, MonadAsync m)
3800 (IsStream t, MonadAsync m)
3800− => (t m Int -> t m Int)
3802+ -> (t m Int -> t m Int)
3801 -> Fold m Int b
3803 -> Fold m Int b
3802 -> t m a
3804 -> t m a
3803 -> t m a
3805 -> t m a
3804−pollCounts transf f xs =
3806+pollCounts predicate transf f xs =
3805 D.fromStreamD
3807 D.fromStreamD
3806− $ D.pollCounts (D.toStreamD . transf . D.fromStreamD) f
3808+ $ D.pollCounts predicate (D.toStreamD . transf . D.fromStreamD) f
3807 $ (D.toStreamD xs)
3809 $ (D.toStreamD xs)
3809-- | Calls the supplied function with the number of elements consumed
3811-- | Calls the supplied function with the number of elements consumed