on master help sign in
Move common Channel type from Data.Stream to Data
3f489cfHarendra Kumar
src/Streamly/Internal/Data/Channel.hsnew file+19
@@ -0,0 +1,19 @@
1+-- |
2+-- Module : Streamly.Internal.Data.Channel
3+-- Copyright : (c) 2017 Composewell Technologies
4+-- License : BSD-3-Clause
5+-- Maintainer : streamly@composewell.com
6+-- Stability : experimental
7+-- Portability : GHC
8+
9+module Streamly.Internal.Data.Channel
10+ (
11+ module Streamly.Internal.Data.Channel.Dispatcher
12+ , module Streamly.Internal.Data.Channel.Types
13+ , module Streamly.Internal.Data.Channel.Worker
14+ )
15+where
16+
17+import Streamly.Internal.Data.Channel.Dispatcher
18+import Streamly.Internal.Data.Channel.Types
19+import Streamly.Internal.Data.Channel.Worker
src/Streamly/Internal/Data/Stream/Channel/Dispatcher.hs → src/Streamly/Internal/Data/Channel/Dispatcher.hsrenamed+3−3
@@ -1,5 +1,5 @@
1-- |
1-- |
2−-- Module : Streamly.Internal.Data.Stream.Channel.Dispatcher
2+-- Module : Streamly.Internal.Data.Channel.Dispatcher
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4-- License : BSD-3-Clause
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
@@ -7,7 +7,7 @@
7-- Portability : GHC
7-- Portability : GHC
8--
8--
9--
9--
10−module Streamly.Internal.Data.Stream.Channel.Dispatcher
10+module Streamly.Internal.Data.Channel.Dispatcher
11 (
11 (
12 -- * Latency collection
12 -- * Latency collection
13 minThreadDelay
13 minThreadDelay
@@ -40,7 +40,7 @@ import Streamly.Internal.Data.Time.Units
40
40
41import qualified Data.Set as S
41import qualified Data.Set as S
42
42
43−import Streamly.Internal.Data.Stream.Channel.Types
43+import Streamly.Internal.Data.Channel.Types
44
44
45-------------------------------------------------------------------------------
45-------------------------------------------------------------------------------
46-- Worker latency data processing
46-- Worker latency data processing
src/Streamly/Internal/Data/Stream/Channel/Types.hs → src/Streamly/Internal/Data/Channel/Types.hsrenamed+2−2
@@ -1,5 +1,5 @@
1-- |
1-- |
2−-- Module : Streamly.Internal.Data.Stream.Channel.Types
2+-- Module : Streamly.Internal.Data.Channel.Types
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4-- License : BSD-3-Clause
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
@@ -31,7 +31,7 @@
31-- consumer is not pulling fast enough. The number of workers may even get
31-- consumer is not pulling fast enough. The number of workers may even get
32-- reduced depending on the consuming pace.
32-- reduced depending on the consuming pace.
33--
33--
34−module Streamly.Internal.Data.Stream.Channel.Types
34+module Streamly.Internal.Data.Channel.Types
35 (
35 (
36 -- * Types
36 -- * Types
37 Count (..)
37 Count (..)
src/Streamly/Internal/Data/Stream/Channel/Worker.hs → src/Streamly/Internal/Data/Channel/Worker.hsrenamed+3−3
@@ -1,5 +1,5 @@
1-- |
1-- |
2−-- Module : Streamly.Internal.Data.Stream.Concurrent.Channel.Worker
2+-- Module : Streamly.Internal.Data.Channel.Worker
3-- Copyright : (c) 2017 Composewell Technologies
3-- Copyright : (c) 2017 Composewell Technologies
4-- License : BSD-3-Clause
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
@@ -8,7 +8,7 @@
8--
8--
9-- Collecting results from child workers in a streamed fashion
9-- Collecting results from child workers in a streamed fashion
10
10
11−module Streamly.Internal.Data.Stream.Channel.Worker
11+module Streamly.Internal.Data.Channel.Worker
12 (
12 (
13 Work (..)
13 Work (..)
14 , estimateWorkers
14 , estimateWorkers
@@ -34,7 +34,7 @@ import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
34import Streamly.Internal.Data.Time.Units
34import Streamly.Internal.Data.Time.Units
35 (AbsTime, NanoSecond64(..), diffAbsTime64, fromRelTime64)
35 (AbsTime, NanoSecond64(..), diffAbsTime64, fromRelTime64)
36
36
37−import Streamly.Internal.Data.Stream.Channel.Types
37+import Streamly.Internal.Data.Channel.Types
38
38
39-------------------------------------------------------------------------------
39-------------------------------------------------------------------------------
40-- Yield control
40-- Yield control
src/Streamly/Internal/Data/Fold/Concurrent/Channel.hs+2−2
@@ -26,11 +26,11 @@ import Control.Monad.IO.Class (MonadIO(liftIO))
26import Data.IORef (writeIORef)
26import Data.IORef (writeIORef)
27import Streamly.Internal.Control.Concurrent (MonadAsync)
27import Streamly.Internal.Control.Concurrent (MonadAsync)
28import Streamly.Internal.Data.Fold (Fold(..), Step (..))
28import Streamly.Internal.Data.Fold (Fold(..), Step (..))
29−import Streamly.Internal.Data.Stream.Channel.Worker (sendWithDoorBell)
29+import Streamly.Internal.Data.Channel.Worker (sendWithDoorBell)
30import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
30import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
31
31
32import Streamly.Internal.Data.Fold.Concurrent.Channel.Type
32import Streamly.Internal.Data.Fold.Concurrent.Channel.Type
33−import Streamly.Internal.Data.Stream.Channel.Types
33+import Streamly.Internal.Data.Channel.Types
34
34
35-------------------------------------------------------------------------------
35-------------------------------------------------------------------------------
36-- Evaluating a Fold
36-- Evaluating a Fold
src/Streamly/Internal/Data/Fold/Concurrent/Channel/Type.hs+3−3
@@ -30,13 +30,13 @@ import Streamly.Internal.Control.Concurrent
30 (MonadAsync, MonadRunInIO, askRunInIO)
30 (MonadAsync, MonadRunInIO, askRunInIO)
31import Streamly.Internal.Control.ForkLifted (doForkWith)
31import Streamly.Internal.Control.ForkLifted (doForkWith)
32import Streamly.Internal.Data.Fold (Fold(..))
32import Streamly.Internal.Data.Fold (Fold(..))
33−import Streamly.Internal.Data.Stream.Channel.Dispatcher (dumpSVarStats)
33+import Streamly.Internal.Data.Channel.Dispatcher (dumpSVarStats)
34−import Streamly.Internal.Data.Stream.Channel.Worker (sendWithDoorBell)
34+import Streamly.Internal.Data.Channel.Worker (sendWithDoorBell)
35
35
36import qualified Streamly.Internal.Data.Fold as Fold
36import qualified Streamly.Internal.Data.Fold as Fold
37import qualified Streamly.Internal.Data.Stream as D
37import qualified Streamly.Internal.Data.Stream as D
38
38
39−import Streamly.Internal.Data.Stream.Channel.Types
39+import Streamly.Internal.Data.Channel.Types
40
40
41data Channel m a b = Channel
41data Channel m a b = Channel
42 {
42 {
src/Streamly/Internal/Data/Stream/Concurrent.hs+3−3
@@ -104,9 +104,9 @@ import Control.Monad (void, when)
104import Control.Monad.IO.Class (MonadIO(liftIO))
104import Control.Monad.IO.Class (MonadIO(liftIO))
105import Streamly.Internal.Control.Concurrent (MonadAsync, askRunInIO)
105import Streamly.Internal.Control.Concurrent (MonadAsync, askRunInIO)
106import Streamly.Internal.Control.ForkLifted (forkManaged)
106import Streamly.Internal.Control.ForkLifted (forkManaged)
107−import Streamly.Internal.Data.Stream.Channel.Dispatcher (modifyThread)
107+import Streamly.Internal.Data.Channel.Dispatcher (modifyThread)
108−import Streamly.Internal.Data.Stream.Channel.Types (ChildEvent(..))
108+import Streamly.Internal.Data.Channel.Types (ChildEvent(..))
109−import Streamly.Internal.Data.Stream.Channel.Worker (sendWithDoorBell)
109+import Streamly.Internal.Data.Channel.Worker (sendWithDoorBell)
110import Streamly.Internal.Data.Stream (Stream, Step(..))
110import Streamly.Internal.Data.Stream (Stream, Step(..))
111import Streamly.Internal.Data.SVar.Type (adaptState)
111import Streamly.Internal.Data.SVar.Type (adaptState)
112
112
src/Streamly/Internal/Data/Stream/Concurrent/Channel.hs+1−1
@@ -62,7 +62,7 @@ import qualified Streamly.Internal.Data.Stream.Concurrent.Channel.Interleave
62import qualified Streamly.Internal.Data.StreamK as K
62import qualified Streamly.Internal.Data.StreamK as K
63
63
64import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
64import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
65−import Streamly.Internal.Data.Stream.Channel.Types
65+import Streamly.Internal.Data.Channel.Types
66
66
67-- | Create a new concurrent stream evaluation channel. The monad
67-- | Create a new concurrent stream evaluation channel. The monad
68-- state used to run the stream actions is captured from the call site of
68-- state used to run the stream actions is captured from the call site of
src/Streamly/Internal/Data/Stream/Concurrent/Channel/Append.hs+3−3
@@ -32,7 +32,7 @@ import Streamly.Internal.Control.Concurrent
32 (MonadRunInIO, RunInIO(..), askRunInIO, restoreM)
32 (MonadRunInIO, RunInIO(..), askRunInIO, restoreM)
33import Streamly.Internal.Data.Atomics
33import Streamly.Internal.Data.Atomics
34 (atomicModifyIORefCAS, atomicModifyIORefCAS_)
34 (atomicModifyIORefCAS, atomicModifyIORefCAS_)
35−import Streamly.Internal.Data.Stream.Channel.Dispatcher (modifyThread)
35+import Streamly.Internal.Data.Channel.Dispatcher (modifyThread)
36
36
37import qualified Data.Heap as H
37import qualified Data.Heap as H
38import qualified Data.Set as Set
38import qualified Data.Set as Set
@@ -41,8 +41,8 @@ import qualified Streamly.Internal.Data.StreamK as K
41import Streamly.Internal.Data.Stream.Concurrent.Channel.Consumer
41import Streamly.Internal.Data.Stream.Concurrent.Channel.Consumer
42import Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
42import Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
43import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
43import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
44−import Streamly.Internal.Data.Stream.Channel.Types
44+import Streamly.Internal.Data.Channel.Types
45−import Streamly.Internal.Data.Stream.Channel.Worker
45+import Streamly.Internal.Data.Channel.Worker
46
46
47------------------------------------------------------------------------------
47------------------------------------------------------------------------------
48-- Concurrent streams with first-come-first serve results
48-- Concurrent streams with first-come-first serve results
src/Streamly/Internal/Data/Stream/Concurrent/Channel/Consumer.hs+2−2
@@ -25,8 +25,8 @@ import Streamly.Internal.Control.Concurrent (MonadRunInIO)
25
25
26import Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
26import Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
27import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
27import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
28−import Streamly.Internal.Data.Stream.Channel.Dispatcher
28+import Streamly.Internal.Data.Channel.Dispatcher
29−import Streamly.Internal.Data.Stream.Channel.Types
29+import Streamly.Internal.Data.Channel.Types
30
30
31-------------------------------------------------------------------------------
31-------------------------------------------------------------------------------
32-- Reading from the workers' output queue/buffer
32-- Reading from the workers' output queue/buffer
src/Streamly/Internal/Data/Stream/Concurrent/Channel/Dispatcher.hs+3−3
@@ -34,9 +34,9 @@ import Streamly.Internal.Data.Time.Units
34 (MicroSecond64(..), diffAbsTime64, fromRelTime64, toRelTime64)
34 (MicroSecond64(..), diffAbsTime64, fromRelTime64, toRelTime64)
35
35
36import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
36import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
37−import Streamly.Internal.Data.Stream.Channel.Dispatcher
37+import Streamly.Internal.Data.Channel.Dispatcher
38−import Streamly.Internal.Data.Stream.Channel.Types
38+import Streamly.Internal.Data.Channel.Types
39−import Streamly.Internal.Data.Stream.Channel.Worker
39+import Streamly.Internal.Data.Channel.Worker
40
40
41-------------------------------------------------------------------------------
41-------------------------------------------------------------------------------
42-- Dispatching workers
42-- Dispatching workers
src/Streamly/Internal/Data/Stream/Concurrent/Channel/Interleave.hs+2−2
@@ -21,14 +21,14 @@ import Data.Concurrent.Queue.MichaelScott (LinkedQueue, newQ, nullQ, tryPopR, pu
21import Data.IORef (newIORef, readIORef)
21import Data.IORef (newIORef, readIORef)
22import Streamly.Internal.Control.Concurrent
22import Streamly.Internal.Control.Concurrent
23 (MonadRunInIO, MonadAsync, RunInIO(..), askRunInIO, restoreM)
23 (MonadRunInIO, MonadAsync, RunInIO(..), askRunInIO, restoreM)
24−import Streamly.Internal.Data.Stream.Channel.Dispatcher (delThread)
24+import Streamly.Internal.Data.Channel.Dispatcher (delThread)
25
25
26import qualified Data.Set as Set
26import qualified Data.Set as Set
27import qualified Streamly.Internal.Data.StreamK as K
27import qualified Streamly.Internal.Data.StreamK as K
28
28
29import Streamly.Internal.Data.Stream.Concurrent.Channel.Consumer
29import Streamly.Internal.Data.Stream.Concurrent.Channel.Consumer
30import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
30import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
31−import Streamly.Internal.Data.Stream.Channel.Types
31+import Streamly.Internal.Data.Channel.Types
32
32
33------------------------------------------------------------------------------
33------------------------------------------------------------------------------
34-- Creating a channel
34-- Creating a channel
src/Streamly/Internal/Data/Stream/Concurrent/Channel/Operations.hs+1−1
@@ -44,7 +44,7 @@ import qualified Streamly.Internal.Data.StreamK as K
44
44
45import Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
45import Streamly.Internal.Data.Stream.Concurrent.Channel.Dispatcher
46import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
46import Streamly.Internal.Data.Stream.Concurrent.Channel.Type
47−import Streamly.Internal.Data.Stream.Channel.Types hiding (inspect)
47+import Streamly.Internal.Data.Channel.Types hiding (inspect)
48
48
49import Prelude hiding (map, concat, concatMap)
49import Prelude hiding (map, concat, concatMap)
50
50
src/Streamly/Internal/Data/Stream/Concurrent/Channel/Type.hs+3−3
@@ -25,12 +25,12 @@ import Data.List (intersperse)
25import Data.Set (Set)
25import Data.Set (Set)
26import Streamly.Internal.Control.Concurrent (RunInIO)
26import Streamly.Internal.Control.Concurrent (RunInIO)
27import Streamly.Internal.Data.Atomics (atomicModifyIORefCAS_)
27import Streamly.Internal.Data.Atomics (atomicModifyIORefCAS_)
28−import Streamly.Internal.Data.Stream.Channel.Dispatcher (dumpSVarStats)
28+import Streamly.Internal.Data.Channel.Dispatcher (dumpSVarStats)
29−import Streamly.Internal.Data.Stream.Channel.Worker
29+import Streamly.Internal.Data.Channel.Worker
30 (sendYield, sendStop, sendWithDoorBell)
30 (sendYield, sendStop, sendWithDoorBell)
31import Streamly.Internal.Data.StreamK (StreamK)
31import Streamly.Internal.Data.StreamK (StreamK)
32
32
33−import Streamly.Internal.Data.Stream.Channel.Types
33+import Streamly.Internal.Data.Channel.Types
34
34
35-- IMPORTANT NOTE: we cannot update the SVar after generating it as we have
35-- IMPORTANT NOTE: we cannot update the SVar after generating it as we have
36-- references to the original SVar stored in several functions which will keep
36-- references to the original SVar stored in several functions which will keep
streamly.cabal+6−4
@@ -363,6 +363,7 @@ library
363 -- graphmod | dot -Tps > deps.ps
363 -- graphmod | dot -Tps > deps.ps
364 Streamly.Internal.Data.IsMap.HashMap
364 Streamly.Internal.Data.IsMap.HashMap
365 , Streamly.Internal.Data.Cont
365 , Streamly.Internal.Data.Cont
366+ , Streamly.Internal.Data.Channel
366 , Streamly.Internal.Data.Stream.MkType
367 , Streamly.Internal.Data.Stream.MkType
367
368
368 -- streamly-concurrent
369 -- streamly-concurrent
@@ -370,9 +371,6 @@ library
370 , Streamly.Internal.Control.ForkLifted
371 , Streamly.Internal.Control.ForkLifted
371 , Streamly.Internal.Data.Atomics
372 , Streamly.Internal.Data.Atomics
372 , Streamly.Internal.Data.IOFinalizer.Lifted
373 , Streamly.Internal.Data.IOFinalizer.Lifted
373− , Streamly.Internal.Data.Stream.Channel.Types
374− , Streamly.Internal.Data.Stream.Channel.Dispatcher
375− , Streamly.Internal.Data.Stream.Channel.Worker
376
374
377 , Streamly.Internal.Data.Unfold.Prelude
375 , Streamly.Internal.Data.Unfold.Prelude
378 , Streamly.Internal.Data.Fold.Prelude
376 , Streamly.Internal.Data.Fold.Prelude
@@ -451,7 +449,11 @@ library
451 exposed-modules: Streamly.Internal.FileSystem.Event
449 exposed-modules: Streamly.Internal.FileSystem.Event
452
450
453 other-modules:
451 other-modules:
452+ Streamly.Internal.Data.Channel.Types
453+ , Streamly.Internal.Data.Channel.Dispatcher
454+ , Streamly.Internal.Data.Channel.Worker
455+
454− Streamly.Data.Stream.Exception
456+ , Streamly.Data.Stream.Exception
455 , Streamly.Data.Stream.Concurrent
457 , Streamly.Data.Stream.Concurrent
456 , Streamly.Data.Stream.Time
458 , Streamly.Data.Stream.Time
457
459