|
Control.Concurrent.SCC.ComponentTypes |
|
|
|
|
|
Synopsis |
|
class Component c where | | | class BranchComponent cc m x r | cc -> m x where | | | data AnyComponent = forall a . Component a => AnyComponent a | | data Performer m r = Performer {} | | data Consumer m x r = Consumer {} | | data Producer m x r = Producer {} | | data Splitter m x = Splitter {} | | data Transducer m x y = Transducer {} | | data ComponentConfiguration = ComponentConfiguration {} | | liftPerformer :: String -> Int -> (Int -> (ComponentConfiguration, forall c. Pipe c m r)) -> Performer m r | | liftConsumer :: String -> Int -> (Int -> (ComponentConfiguration, forall c. Source c x -> Pipe c m r)) -> Consumer m x r | | liftAtomicConsumer :: String -> Int -> (forall c. Source c x -> Pipe c m r) -> Consumer m x r | | liftProducer :: String -> Int -> (Int -> (ComponentConfiguration, forall c. Sink c x -> Pipe c m r)) -> Producer m x r | | liftAtomicProducer :: String -> Int -> (forall c. Sink c x -> Pipe c m r) -> Producer m x r | | liftTransducer :: String -> Int -> (Int -> (ComponentConfiguration, forall c. Source c x -> Sink c y -> Pipe c m [x])) -> Transducer m x y | | liftAtomicTransducer :: String -> Int -> (forall c. Source c x -> Sink c y -> Pipe c m [x]) -> Transducer m x y | | lift121Transducer :: (Monad m, Typeable x, Typeable y) => String -> (x -> y) -> Transducer m x y | | liftStatelessTransducer :: (Monad m, Typeable x, Typeable y) => String -> (x -> [y]) -> Transducer m x y | | liftFoldTransducer :: (Monad m, Typeable x, Typeable y) => String -> (s -> x -> s) -> s -> (s -> y) -> Transducer m x y | | liftStatefulTransducer :: (Monad m, Typeable x, Typeable y) => String -> (state -> x -> (state, [y])) -> state -> Transducer m x y | | liftSimpleSplitter :: forall m x. (ParallelizableMonad m, Typeable x) => String -> Int -> (Int -> (ComponentConfiguration, forall c. Source c x -> Sink c x -> Sink c x -> Pipe c m [x])) -> Splitter m x | | liftSectionSplitter :: forall m x. (ParallelizableMonad m, Typeable x) => String -> Int -> (Int -> (ComponentConfiguration, forall c. Source c x -> Sink c (Maybe x) -> Sink c (Maybe x) -> Pipe c m [x])) -> Splitter m x | | liftAtomicSimpleSplitter :: forall m x. (ParallelizableMonad m, Typeable x) => String -> Int -> (forall c. Source c x -> Sink c x -> Sink c x -> Pipe c m [x]) -> Splitter m x | | liftAtomicSectionSplitter :: forall m x. (ParallelizableMonad m, Typeable x) => String -> Int -> (forall c. Source c x -> Sink c (Maybe x) -> Sink c (Maybe x) -> Pipe c m [x]) -> Splitter m x | | liftStatelessSplitter :: (ParallelizableMonad m, Typeable x) => String -> (x -> Bool) -> Splitter m x | | showComponentTree :: forall c. Component c => c -> String | | optimalTwoParallelConfigurations :: (Component c1, Component c2) => Int -> c1 -> c2 -> (ComponentConfiguration, c1, c2, Bool) | | optimalTwoSequentialConfigurations :: (Component c1, Component c2) => Int -> c1 -> c2 -> (ComponentConfiguration, c1, c2) | | optimalThreeParallelConfigurations :: (Component c1, Component c2, Component c3) => Int -> c1 -> c2 -> c3 -> (ComponentConfiguration, (c1, Bool), (c2, Bool), (c3, Bool)) |
|
|
|
Classes
|
|
|
The types of Component class carry metadata and can be configured to use a specific number of threads.
| | Methods | | | | Returns the list of all children components.
| | | Returns the maximum number of threads that can be used by the component.
| | | Configures the component to use the specified number of threads. This function affects usedThreads, cost,
and subComponents methods of the result, while name and maxUsableThreads remain the same.
| | | The number of threads that the component is configured to use. By default the number is usually 1.
| | | The cost of using the component as configured.
|
| | Instances | |
|
|
class BranchComponent cc m x r | cc -> m x where | Source |
|
|
|
Types
|
|
|
|
|
|
A component that performs a computation with no inputs nor outputs is a Performer.
| Constructors | | Instances | |
|
|
|
A component that consumes values from a Source is called Consumer.
data Consumer m x r = Consumer {consumerData :: ComponentData (forall c. Source c x -> Pipe c m r),
consume :: forall c. Source c x -> Pipe c m r}
| Constructors | | Instances | (ParallelizableMonad m, Typeable x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x ()) (Performer m ()) | (ParallelizableMonad m, Typeable x, Typeable y) => PipeableComponentPair m y (Transducer m x y) (Consumer m y r) (Consumer m x r) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair TransducerType (ConsumerType ()) TransducerType m ([] x) ([] y) (Transducer m x y) (Consumer m x ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ConsumerType ()) TransducerType TransducerType m ([] x) ([] y) (Consumer m x ()) (Transducer m x y) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ProducerType ()) (ConsumerType ()) TransducerType m ([] x) ([] y) (Producer m y ()) (Consumer m x ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ConsumerType ()) (ProducerType ()) TransducerType m ([] x) ([] y) (Consumer m x ()) (Producer m y ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x) => JoinableComponentPair (PerformerType r1) (ConsumerType r2) (ConsumerType r2) m ([] x) () (Performer m r1) (Consumer m x r2) (Consumer m x r2) | (ParallelizableMonad m, Typeable x) => JoinableComponentPair (ConsumerType r1) (PerformerType r2) (ConsumerType r2) m ([] x) () (Consumer m x r1) (Performer m r2) (Consumer m x r2) | (ParallelizableMonad m, Typeable x) => JoinableComponentPair (ConsumerType ()) (ConsumerType ()) (ConsumerType ()) m ([] x) () (Consumer m x ()) (Consumer m x ()) (Consumer m x ()) | Component (Consumer m x r) | Monad m => BranchComponent (Consumer m x r) m x r | Monad m => BranchComponent (Consumer m x ()) m x ([] x) | AnyListOrUnit y => CompatibleSignature (Consumer m x r) (ConsumerType r) m ([] x) y |
|
|
|
|
A component that produces values and puts them into a Sink is called Producer.
| Constructors | | Instances | (ParallelizableMonad m, Typeable x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x ()) (Performer m ()) | (ParallelizableMonad m, Typeable x, Typeable y) => PipeableComponentPair m x (Producer m x r) (Transducer m x y) (Producer m y r) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair TransducerType (ProducerType ()) TransducerType m ([] x) ([] y) (Transducer m x y) (Producer m y ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ProducerType ()) TransducerType TransducerType m ([] x) ([] y) (Producer m y ()) (Transducer m x y) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ProducerType ()) (ConsumerType ()) TransducerType m ([] x) ([] y) (Producer m y ()) (Consumer m x ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ConsumerType ()) (ProducerType ()) TransducerType m ([] x) ([] y) (Consumer m x ()) (Producer m y ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x) => JoinableComponentPair (PerformerType r1) (ProducerType r2) (ProducerType r2) m () ([] x) (Performer m r1) (Producer m x r2) (Producer m x r2) | (ParallelizableMonad m, Typeable x) => JoinableComponentPair (ProducerType r1) (PerformerType r2) (ProducerType r2) m () ([] x) (Producer m x r1) (Performer m r2) (Producer m x r2) | (Monad m, Typeable x) => JoinableComponentPair (ProducerType r1) (ProducerType r2) (ProducerType r2) m () ([] x) (Producer m x r1) (Producer m x r2) (Producer m x r2) | Component (Producer m x r) | AnyListOrUnit y => CompatibleSignature (Producer m x r) (ProducerType r) m y ([] x) |
|
|
|
|
The Splitter type represents computations that distribute data acording to some criteria. A splitter should
distribute only the original input data, and feed it into the sinks in the same order it has been read from the
source. If the two sink arguments of a splitter are the same, the splitter must act as an identity transform.
| Constructors | | Instances | |
|
|
|
The Transducer type represents computations that transform data and return no result.
A transducer must continue consuming the given source and feeding the sink while there is data.
| Constructors | | Instances | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair TransducerType TransducerType TransducerType m ([] x) ([] y) (Transducer m x y) (Transducer m x y) (Transducer m x y) | ParallelizableMonad m => PipeableComponentPair m y (Transducer m x y) (Transducer m y z) (Transducer m x z) | (ParallelizableMonad m, Typeable x, Typeable y) => PipeableComponentPair m x (Producer m x r) (Transducer m x y) (Producer m y r) | (ParallelizableMonad m, Typeable x, Typeable y) => PipeableComponentPair m y (Transducer m x y) (Consumer m y r) (Consumer m x r) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair TransducerType (PerformerType r) TransducerType m ([] x) ([] y) (Transducer m x y) (Performer m r) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair TransducerType (ProducerType ()) TransducerType m ([] x) ([] y) (Transducer m x y) (Producer m y ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair TransducerType (ConsumerType ()) TransducerType m ([] x) ([] y) (Transducer m x y) (Consumer m x ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (PerformerType r) TransducerType TransducerType m ([] x) ([] y) (Performer m r) (Transducer m x y) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ProducerType ()) TransducerType TransducerType m ([] x) ([] y) (Producer m y ()) (Transducer m x y) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ConsumerType ()) TransducerType TransducerType m ([] x) ([] y) (Consumer m x ()) (Transducer m x y) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ProducerType ()) (ConsumerType ()) TransducerType m ([] x) ([] y) (Producer m y ()) (Consumer m x ()) (Transducer m x y) | (ParallelizableMonad m, Typeable x, Typeable y) => JoinableComponentPair (ConsumerType ()) (ProducerType ()) TransducerType m ([] x) ([] y) (Consumer m x ()) (Producer m y ()) (Transducer m x y) | Component (Transducer m x y) | BranchComponent (Transducer m x y) m x ([] x) | CompatibleSignature (Transducer m x y) TransducerType m ([] x) ([] y) |
|
|
|
data ComponentConfiguration | Source |
|
|
|
Lifting functions
|
|
|
Function liftPerformer takes a component name, maximum number of threads it can use, and its usingThreads
method, and returns a Performer component.
|
|
|
Function liftConsumer takes a component name, maximum number of threads it can use, and its usingThreads
method, and returns a Consumer component.
|
|
|
Function liftAtomicConsumer lifts a single-threaded consume function into a Consumer component.
|
|
|
Function liftProducer takes a component name, maximum number of threads it can use, and its usingThreads
method, and returns a Producer component.
|
|
|
Function liftAtomicProducer lifts a single-threaded produce function into a Producer component.
|
|
|
Function liftTransducer takes a component name, maximum number of threads it can use, and its usingThreads
method, and returns a Transducer component.
|
|
|
Function liftAtomicTransducer lifts a single-threaded transduce function into a Transducer component.
|
|
|
Function lift121Transducer takes a function that maps one input value to one output value each, and lifts it into
a Transducer.
|
|
|
Function liftStatelessTransducer takes a function that maps one input value into a list of output values, and
lifts it into a Transducer.
|
|
|
Function liftFoldTransducer creates a stateful transducer that produces only one output value after consuming the
entire input. Similar to Data.List.foldl
|
|
|
Function liftStatefulTransducer constructs a Transducer from a state-transition function and the initial
state. The transition function may produce arbitrary output at any transition step.
|
|
|
Function liftSimpleSplitter lifts a simple, non-sectioning splitter function into a full Splitter.
|
|
|
Function liftSectionSplitter lifts a sectioning splitter function into a full Splitter
|
|
|
Function liftAtomicSimpleSplitter lifts a single-threaded split function into a Splitter component.
|
|
|
Function liftAtomicSectionSplitter lifts a single-threaded splitSections function into a full Splitter
component.
|
|
|
Function liftStatelessSplitter takes a function that assigns a Boolean value to each input item and lifts it into
a Splitter.
|
|
Utility functions
|
|
|
Show details of the given component's configuration.
|
|
|
Function optimalTwoParallelConfigurations configures two components assuming they can be run in parallel,
splitting the given thread count between them, and returns the configured components, a ComponentConfiguration that
can be used to build a new component from them, and a flag that indicates if they should be run in parallel or
sequentially for optimal resource usage.
|
|
|
Function optimalTwoParallelConfigurations configures two components, both of them with the full thread count, and
returns the components and a ComponentConfiguration that can be used to build a new component from them.
|
|
|
Function optimalThreeParallelConfigurations configures three components assuming they can be run in parallel,
splitting the given thread count between them, and returns the components, a ComponentConfiguration that can be
used to build a new component from them, and a flag per component that indicates if it should be run in parallel or
sequentially for optimal resource usage.
|
|
Produced by Haddock version 2.3.0 |