Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|
Wire concurrency.
Warning: This module is highly experimental and currently causes space leaks. Please use wire concurrency only for short-lived threads.
- class Arrow >~ => WFork (>~) where
- data WireMgr
- startWireMgr :: IO WireMgr
- stopWireMgr :: WireMgr -> IO ()
- withWireMgr :: (MonadBaseControl IO m, MonadIO m) => (WireMgr -> m a) -> m a
- data WireChan a b
- feedWireChan :: WireChan a b -> a -> IO ()
- readWireChan :: WireChan a b -> IO b
- data WireThread
- killWireThread :: WireMgr -> WireThread -> IO ()
Embedding concurrent wires
class Arrow >~ => WFork (>~) whereSource
Forking wire transformer. Creates a concurrent wire thread and opens a communication channel to it.
feedWire :: Wire e >~ (WireChan a b, a) ()Source
Feed a wire thread with additional input.
- Depends: Current instant.
forkWire :: Wire e >~ (Wire e >~ a b, WireMgr) (WireChan a b, WireThread)Source
Fork the input wire using the input wire manager.
Note: This wire forks at every instant. In many cases you will
want to use the swallow
wire transformer with this.
- Depends: Current instant.
queryWire :: Monoid e => Wire e >~ (WireChan a b) bSource
Asks the given wire for its next output.
- Depends: Current instant.
- Inhibits: When there is no data.
(MonadBaseControl IO m, MonadIO m) => WFork (Kleisli m) |
Wire thread manager
startWireMgr :: IO WireMgrSource
Start a wire manager.
stopWireMgr :: WireMgr -> IO ()Source
Stop a wire manager terminating all threads it keeps track of.
withWireMgr :: (MonadBaseControl IO m, MonadIO m) => (WireMgr -> m a) -> m aSource
Convenient wrapper around startWireMgr
and stopWireMgr
.
Wire threads
Channels
A wire channel allows you to send input to and receive output from a concurrently running wire.
feedWireChan :: WireChan a b -> a -> IO ()Source
Feed the given wire thread with input.
readWireChan :: WireChan a b -> IO bSource
Read the given wire's next output.
Threads
data WireThread Source
A wire thread is a concurrently running wire.
killWireThread :: WireMgr -> WireThread -> IO ()Source
Kill the given wire thread.