Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 (receiveMessage SP >>= (logMsg . fromMaybe "Huh!??" . fromDynamic))))
>>>
fooPid
<0.1.0>
>>>
submit s (sendMessageAs SP fooPid "test")
test
>>>
submit s (sendShutdown SP fooPid)
Since: extensible-effects-concurrent-0.3.0.1
Synopsis
- data SchedulerSession r
- forkInteractiveScheduler :: forall r. SetMember Lift (Lift IO) r => (Eff (Process r ': r) () -> IO ()) -> IO (SchedulerSession r)
- killInteractiveScheduler :: SchedulerSession r -> IO ()
- submit :: forall r a. SetMember Lift (Lift IO) r => SchedulerSession r -> Eff (Process r ': r) a -> IO a
- submitCast :: forall o r. (SetMember Lift (Lift IO) r, Typeable o) => SchedulerSession r -> Server o -> Api o Asynchronous -> IO ()
- submitCall :: forall o q r. (SetMember Lift (Lift IO) r, Typeable o, Typeable 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 (Process r ': 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 schedulder immediately using an asynchronous exception.
submit :: forall r a. SetMember Lift (Lift IO) r => SchedulerSession r -> Eff (Process r ': 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) => SchedulerSession r -> Server o -> Api o Asynchronous -> IO () Source #