| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- schedule :: Eff (ConsProcess SchedulerIO) () -> LogChannel LogMessage -> IO ()
- defaultMain :: Eff (ConsProcess SchedulerIO) () -> IO ()
- defaultMainWithLogChannel :: LogChannel LogMessage -> Eff (ConsProcess SchedulerIO) () -> IO ()
- data SchedulerError
- type SchedulerIO = '[Reader SchedulerVar, Logs LogMessage, Lift IO]
- forkIoScheduler :: SchedulerProxy SchedulerIO
- type HasSchedulerIO r = (HasCallStack, SetMember Lift (Lift IO) r, Member (Logs LogMessage) r, Member (Reader SchedulerVar) r)
Documentation
schedule :: Eff (ConsProcess SchedulerIO) () -> LogChannel LogMessage -> 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 LogMessage -> 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 process info was found for a |
| 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. |
Instances
| Show SchedulerError Source # | |
Defined in Control.Eff.Concurrent.Process.ForkIOScheduler Methods showsPrec :: Int -> SchedulerError -> ShowS # show :: SchedulerError -> String # showList :: [SchedulerError] -> ShowS # | |
| Exception SchedulerError Source # | |
Defined in Control.Eff.Concurrent.Process.ForkIOScheduler Methods toException :: SchedulerError -> SomeException # | |
type SchedulerIO = '[Reader SchedulerVar, Logs LogMessage, 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 LogMessage) r, Member (Reader SchedulerVar) r) Source #