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

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Process.Interactive

Description

This module provides support for executing Process actions from IO.

One use case is interacting with processes from the REPL, e.g.:

>>> import Control.Eff.Concurrent.Process.SingleThreadedScheduler (defaultMain)
>>> import Control.Eff.Loop
>>> import Data.Dynamic
>>> import Data.Maybe
>>> s <- forkInteractiveScheduler Control.Eff.Concurrent.Process.SingleThreadedScheduler.defaultMain
>>> fooPid <- submit s (spawn (foreverCheap (receiveAnyMessage SP >>= (logMsg . fromMaybe "Huh!??" . fromDynamic))))
>>> fooPid
<0.1.0>
>>> submit s (sendMessageAs SP fooPid "test")
test
>>> submit s (sendShutdown SP fooPid)

Since: 0.3.0.1

Synopsis

Documentation

data SchedulerSession r Source #

Contains the communication channels to interact with a scheduler running in its' own thread.

forkInteractiveScheduler :: forall r. SetMember Lift (Lift IO) r => (Eff (Processes r) () -> IO ()) -> IO (SchedulerSession r) Source #

Fork a scheduler with a process that communicates with it via MVar, which is also the reason for the Lift IO constraint.

killInteractiveScheduler :: SchedulerSession r -> IO () Source #

Exit the scheduler immediately using an asynchronous exception.

submit :: forall r a. SetMember Lift (Lift IO) r => SchedulerSession r -> Eff (Processes r) a -> IO a Source #

Send a Process effect to the main process of a scheduler, this blocks until the effect is executed.

submitCast :: forall o r. (SetMember Lift (Lift IO) r, HasPdu o, Tangible (Pdu o Asynchronous), Member Interrupts r) => SchedulerSession r -> Endpoint o -> Pdu o Asynchronous -> IO () Source #

Combination of submit and cast.

submitCall :: forall o q r. (SetMember Lift (Lift IO) r, Member Interrupts r, Tangible (Pdu o (Synchronous q)), HasPdu o, Tangible q) => SchedulerSession r -> Endpoint o -> Pdu o (Synchronous q) -> IO q Source #

Combination of submit and cast.