extensible-effects-concurrent-0.1.2.2: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

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.

Synopsis

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 Dynamic value could not be converted to the expected value using fromDynamic.

ProcessNotFound ProcessId

No ProcessInfo was found for a ProcessId during internal processing. NOTE: This is **ONLY** caused by internal errors, probably by an incorrect MessagePassing handler in this module. **Sending a message to a process ALWAYS succeeds!** Even if the process does not exist.

ProcessException String ProcessId

A process called raiseError.

DispatcherShuttingDown

An action was not performed while the dispatcher was exiting.

LowLevelIOException SomeException

SomeException was caught while dispatching messages.

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 #

An alias for the constraints for the effects essential to this dispatcher implementation, i.e. these effects allow spawning new Processes. @see DispatcherIO

type ProcIO = ConsProcIO DispatcherIO Source #

The concrete list of Effects that provide MessagePassing and Processes ontop of DispatcherIO