@@ -20,13 +20,13 @@ module Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
23−import Control.Monad.Trans.Control (MonadBaseControl)
24import Control.Concurrent (takeMVar, threadDelay)
23import Control.Concurrent (takeMVar, threadDelay)
25import Control.Exception (assert)
24import Control.Exception (assert)
26import Control.Monad (when, void)
25import Control.Monad (when, void)
27import Control.Monad.IO.Class (MonadIO(liftIO))
26import Control.Monad.IO.Class (MonadIO(liftIO))
28import Data.Maybe (fromJust, fromMaybe)
27import Data.Maybe (fromJust, fromMaybe)
29import Data.IORef (modifyIORef, newIORef, readIORef, writeIORef)
28import Data.IORef (modifyIORef, newIORef, readIORef, writeIORef)
29+import Streamly.Internal.Control.Concurrent (MonadRunInIO)
30import Streamly.Internal.Control.ForkLifted (doFork)
30import Streamly.Internal.Control.ForkLifted (doFork)
31import Streamly.Internal.Data.Atomics (atomicModifyIORefCAS_, storeLoadBarrier)
31import Streamly.Internal.Data.Atomics (atomicModifyIORefCAS_, storeLoadBarrier)
32import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
32import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
@@ -43,7 +43,7 @@ import Streamly.Internal.Data.Stream.Channel.Worker
43-------------------------------------------------------------------------------
43-------------------------------------------------------------------------------
45{-# NOINLINE pushWorker #-}
45{-# NOINLINE pushWorker #-}
46−pushWorker :: (MonadIO m, MonadBaseControl IO m) => Count -> Channel m a -> m ()
46+pushWorker :: MonadRunInIO m => Count -> Channel m a -> m ()
47pushWorker yieldMax sv = do
47pushWorker yieldMax sv = do
48 liftIO $ atomicModifyIORefCAS_ (workerCount sv) $ \n -> n + 1
48 liftIO $ atomicModifyIORefCAS_ (workerCount sv) $ \n -> n + 1
49 when (svarInspectMode sv)
49 when (svarInspectMode sv)
@@ -130,7 +130,7 @@ checkMaxBuffer active sv = do
130 (_, n) <- liftIO $ readIORef (outputQueue sv)
130 (_, n) <- liftIO $ readIORef (outputQueue sv)
131 return $ fromIntegral lim > n + active
131 return $ fromIntegral lim > n + active
133−dispatchWorker :: (MonadIO m, MonadBaseControl IO m) =>
133+dispatchWorker :: MonadRunInIO m =>
134 Count -> Channel m a -> m Bool
134 Count -> Channel m a -> m Bool
135dispatchWorker yieldCount sv = do
135dispatchWorker yieldCount sv = do
136 -- XXX in case of Ahead streams we should not send more than one worker
136 -- XXX in case of Ahead streams we should not send more than one worker
@@ -175,7 +175,7 @@ dispatchWorker yieldCount sv = do
175-- Returns:
175-- Returns:
176-- True: can dispatch more
176-- True: can dispatch more
177-- False: full, no more dispatches
177-- False: full, no more dispatches
178−dispatchWorkerPaced :: (MonadIO m, MonadBaseControl IO m) =>
178+dispatchWorkerPaced :: MonadRunInIO m =>
179 Channel m a -> m Bool
179 Channel m a -> m Bool
180dispatchWorkerPaced sv = do
180dispatchWorkerPaced sv = do
181 let yinfo = fromJust $ yieldRateInfo sv
181 let yinfo = fromJust $ yieldRateInfo sv
@@ -382,7 +382,7 @@ sendWorkerWait eagerEval delay dispatch sv = go
382-- | Start the evaluation of the channel's work queue by kicking off a worker.
382-- | Start the evaluation of the channel's work queue by kicking off a worker.
383-- Note: Work queue must not be empty otherwise the worker will exit without
383-- Note: Work queue must not be empty otherwise the worker will exit without
384-- doing anything.
384-- doing anything.
385−startChannel :: (MonadIO m, MonadBaseControl IO m) =>
385+startChannel :: MonadRunInIO m =>
386 Channel m a -> m ()
386 Channel m a -> m ()
387startChannel chan = do
387startChannel chan = do
388 case yieldRateInfo chan of
388 case yieldRateInfo chan of