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 schedule
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.
- schedule :: Eff (ConsProcess SchedulerIO) () -> LogChannel String -> IO ()
- defaultMain :: Eff (ConsProcess SchedulerIO) () -> IO ()
- defaultMainWithLogChannel :: LogChannel String -> Eff (ConsProcess SchedulerIO) () -> IO ()
- data SchedulerError
- type SchedulerIO = '[Reader SchedulerVar, Logs String, Lift IO]
- forkIoScheduler :: SchedulerProxy SchedulerIO
- type HasSchedulerIO r = (HasCallStack, SetMember Lift (Lift IO) r, Member (Logs String) r, Member (Reader SchedulerVar) r)
Documentation
schedule :: Eff (ConsProcess SchedulerIO) () -> LogChannel String -> IO () Source #
This is the main entry point to running a message passing concurrency
application. This function takes a Process
on top of the SchedulerIO
effect and a LogChannel
for concurrent logging.
defaultMain :: Eff (ConsProcess SchedulerIO) () -> IO () Source #
Start the message passing concurrency system then execute a Process
on
top of SchedulerIO
effect. All logging is sent to standard output.
defaultMainWithLogChannel :: LogChannel String -> Eff (ConsProcess SchedulerIO) () -> IO () Source #
Start the message passing concurrency system then execute a Process
on
top of SchedulerIO
effect. All logging is sent to standard output.
data SchedulerError Source #
A sum-type with errors that can occur when scheduleing messages.
ProcessNotFound ProcessId | No |
ProcessRaisedError String | A process called |
ProcessExitError String | A process called |
ProcessShuttingDown | A process exits. |
SchedulerShuttingDown | An action was not performed while the scheduler was exiting. |