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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Process.ForkIOScheduler

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 schedule 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

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.

Constructors

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.

ProcessRaisedError String

A process called raiseError.

ProcessExitError String

A process called exitWithError.

ProcessShuttingDown

A process exits.

SchedulerShuttingDown

An action was not performed while the scheduler was exiting.

type SchedulerIO = '[Reader SchedulerVar, Logs String, Lift IO] Source #

The concrete list of Effects for this scheduler implementation. See HasSchedulerIO

type HasSchedulerIO r = (HasCallStack, SetMember Lift (Lift IO) r, Member (Logs String) r, Member (Reader SchedulerVar) r) Source #

An alias for the constraints for the effects essential to this scheduler implementation, i.e. these effects allow spawning new Processes. See SchedulerIO