Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implement Erlang style message passing concurrency.
This handles the MessagePassing
and Process
effects, using
TQueue
s 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 TVar
s
to manage processes with message queues.
The Eff
handler for Process
and MessagePassing
use
are implemented and available through spawn
.
spawn
uses forkFinally
and TQueue
s 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.
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 Eff
ects 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 Eff
ects that provide MessagePassing
and
Process
es ontop of DispatcherIO