Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Actor message
- adaptToList :: Actor message -> Actor [message]
- spawnStatelessGranular :: (message -> IO ()) -> IO () -> IO (Actor message)
- spawnStatefulGranular :: state -> (state -> message -> IO state) -> (state -> IO ()) -> IO (Actor message)
- spawnStatefulBatched :: state -> (state -> NonEmpty message -> IO state) -> (state -> IO ()) -> IO (Actor message)
- tell :: Actor message -> message -> IO ()
- kill :: Actor message -> IO ()
- wait :: Actor message -> IO ()
Documentation
Controls of an actor, which processes the messages of type message
.
Abstraction over the message channel, thread-forking and killing.
Manipulation
adaptToList :: Actor message -> Actor [message] Source #
Adapt the actor to be able to receive lists of messages.
Acquisition
spawnStatelessGranular Source #
:: (message -> IO ()) | Interpreter of a message. |
-> IO () | Clean up when killed. |
-> IO (Actor message) | Fork a thread to run the handler daemon on and produce a handle to control it. |
Given an interpreter of messages, fork a thread to run the handler daemon on and produce a handle to control that actor.
Killing that actor will make it process all the messages in the queue first. All the messages sent to it after killing won't be processed.
spawnStatefulGranular :: state -> (state -> message -> IO state) -> (state -> IO ()) -> IO (Actor message) Source #
Actor with memory.
Threads a persistent state thru its iterations.
Given an interpreter of messages and initial state generator, forks a thread to run the computation on and produces a handle to address that actor.
Killing that actor will make it process all the messages in the queue first. All the messages sent to it after killing won't be processed.
spawnStatefulBatched :: state -> (state -> NonEmpty message -> IO state) -> (state -> IO ()) -> IO (Actor message) Source #