on master help sign in
maxThrads and maxBuffer should pass on state even in serial streams

otherwise it becomes confusion and hard to debug, when state is not getting passed, later we figure out that it is because of serial stream. Since streams can be changed easily it should not change program behavior.

commita385c6a3bb720645836da7c3703d7e5111238d30 authorHarendra Kumar <harendra.kumar@gmail.com> dateSat 18 Aug 2018, 02:47 (8 years ago) parent5d84fb3
1 file changed+12−4
src/Streamly/Streams/SVar.hs+12−4
src/Streamly/Streams/SVar.hs+12−4
@@ -153,9 +153,11 @@ maxThreads :: IsStream t => Int -> t m a -> t m a
153153maxThreads n m = fromStream $ Stream $ \st stp sng yld -> do
154154 unStream (toStream m) (setMaxThreads n st) stp sng yld
155155
156+{-
156157{-# RULES "maxThreadsSerial serial" maxThreads = maxThreadsSerial #-}
157158maxThreadsSerial :: Int -> SerialT m a -> SerialT m a
158159maxThreadsSerial _ = id
160+-}
159161
160162-- | Specify the maximum size of the buffer for storing the results from
161163-- concurrent computations. If the buffer becomes full we stop spawning more
@@ -176,9 +178,11 @@ maxBuffer :: IsStream t => Int -> t m a -> t m a
176178maxBuffer n m = fromStream $ Stream $ \st stp sng yld -> do
177179 unStream (toStream m) (setMaxBuffer n st) stp sng yld
178180
181+{-
179182{-# RULES "maxBuffer serial" maxBuffer = maxBufferSerial #-}
180183maxBufferSerial :: Int -> SerialT m a -> SerialT m a
181184maxBufferSerial _ = id
185+-}
182186
183187-- | Specify the maximum average pull rate in number of yields per second (i.e.
184188-- @Hertz@) which the consumer of the stream cannot exceed. A value of 0 resets
@@ -199,9 +203,11 @@ yieldRate :: IsStream t => Double -> t m a -> t m a
199203yieldRate n m = fromStream $ Stream $ \st stp sng yld -> do
200204 unStream (toStream m) (setMaxStreamRate n st) stp sng yld
201205
206+{-
202207{-# RULES "yieldRate serial" yieldRate = yieldRateSerial #-}
203208yieldRateSerial :: Double -> SerialT m a -> SerialT m a
204209yieldRateSerial _ = id
210+-}
205211
206212-- | Specify the average latency, in nanoseconds, of a single threaded action
207213-- in a concurrent composition. Streamly can measure the latencies, but that is
@@ -215,14 +221,16 @@ yieldRateSerial _ = id
215221-- This would normally be useful only in high latency and high throughput
216222-- cases.
217223--
218−{-# INLINE_NORMAL serialLatency #-}
219−serialLatency :: IsStream t => Int -> t m a -> t m a
220−serialLatency n m = fromStream $ Stream $ \st stp sng yld -> do
224+{-# INLINE_NORMAL _serialLatency #-}
225+_serialLatency :: IsStream t => Int -> t m a -> t m a
226+_serialLatency n m = fromStream $ Stream $ \st stp sng yld -> do
221227 unStream (toStream m) (setStreamLatency n st) stp sng yld
222228
223−{-# RULES "serialLatency serial" serialLatency = serialLatencySerial #-}
229+{-
230+{-# RULES "serialLatency serial" _serialLatency = serialLatencySerial #-}
224231serialLatencySerial :: Int -> SerialT m a -> SerialT m a
225232serialLatencySerial _ = id
233+-}
226234
227235-- Stop concurrent dispatches after this limit. This is useful in API's like
228236-- "take" where we want to dispatch only upto the number of elements "take"