| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Eff.Concurrent.Dispatcher
Description
Implement Erlang style message passing concurrency.
This handles the MessagePassing and Process effects, using
TQueues and forkIO.
This aims to be a pragmatic implementation, so even logging is supported.
At the core is a main process that enters runMainProcess
and creates all of the internal state stored in TVars
to manage processes with message queues.
The Eff handler for Process and MessagePassing use
are implemented and available through spawn.
spawn uses forkFinally and TQueues and tries to catch
most exceptions.
- runMainProcess :: Eff ProcIO a -> LogChannel String -> IO a
- defaultMain :: Eff ProcIO a -> IO a
- spawn :: HasDispatcherIO r => Eff ProcIO () -> Eff r ProcessId
- data DispatcherError
- type DispatcherIO = '[Exc DispatcherError, Reader DispatcherVar, Logs String, Lift IO]
- type HasDispatcherIO r = (HasCallStack, SetMember Lift (Lift IO) r, Member (Exc DispatcherError) r, Member (Logs String) r, Member (Reader DispatcherVar) r)
- type ProcIO = ConsProcIO DispatcherIO
Documentation
runMainProcess :: Eff ProcIO a -> LogChannel String -> IO a Source #
This is the main entry point to running a message passing concurrency
application. This function takes a ProcIO effect and a LogChannel for
concurrent logging.
defaultMain :: Eff ProcIO a -> IO a Source #
Start the message passing concurrency system then execute a ProcIO effect.
All logging is sent to standard output.
data DispatcherError Source #
A sum-type with errors that can occur when dispatching messages.
Constructors
| UnhandledMessageReceived Dynamic ProcessId | A process message queue contained a bad message and the |
| ProcessNotFound ProcessId | No |
| ProcessException String ProcessId | A process called |
| DispatcherShuttingDown | An action was not performed while the dispatcher was exiting. |
| LowLevelIOException SomeException |
|
type DispatcherIO = '[Exc DispatcherError, Reader DispatcherVar, Logs String, Lift IO] Source #
The concrete list of Effects for this scheduler implementation.
@see HasDispatcherIO
type HasDispatcherIO r = (HasCallStack, SetMember Lift (Lift IO) r, Member (Exc DispatcherError) r, Member (Logs String) r, Member (Reader DispatcherVar) r) Source #
type ProcIO = ConsProcIO DispatcherIO Source #
The concrete list of Effects that provide MessagePassing and
Processes ontop of DispatcherIO