| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- data SchedulerSession r
- forkInteractiveScheduler :: forall r. SetMember Lift (Lift IO) r => (Eff (InterruptableProcess r) () -> IO ()) -> IO (SchedulerSession r)
- killInteractiveScheduler :: SchedulerSession r -> IO ()
- submit :: forall r a. SetMember Lift (Lift IO) r => SchedulerSession r -> Eff (InterruptableProcess r) a -> IO a
- submitCast :: forall o r. (SetMember Lift (Lift IO) r, Typeable o, NFData (Api o Asynchronous), Member Interrupts r) => SchedulerSession r -> Server o -> Api o Asynchronous -> IO ()
- submitCall :: forall o q r. (SetMember Lift (Lift IO) r, Typeable o, Typeable q, NFData q, Show q, Member Interrupts r, NFData (Api o (Synchronous q))) => SchedulerSession r -> Server o -> Api o (Synchronous q) -> IO q
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 (InterruptableProcess 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 (InterruptableProcess 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, Typeable o, NFData (Api o Asynchronous), Member Interrupts r) => SchedulerSession r -> Server o -> Api o Asynchronous -> IO () Source #
submitCall :: forall o q r. (SetMember Lift (Lift IO) r, Typeable o, Typeable q, NFData q, Show q, Member Interrupts r, NFData (Api o (Synchronous q))) => SchedulerSession r -> Server o -> Api o (Synchronous q) -> IO q Source #