Copyright | (c) Well-Typed / Tim Watson |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | Tim Watson <[email protected]> |
Stability | experimental |
Portability | non-portable (requires concurrency) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Control.Distributed.Process.Execution.EventManager
Description
- Overview
The EventManager is a parallel/concurrent event handling tool, built on
top of the Exchange API. Arbitrary events are published to the event
manager using notify
, and are broadcast simulataneously to a set of
registered event handlers.
- Defining and Registering Event Handlers
Event handlers are defined as Serializable m => s -> m -> Process s
,
i.e., an expression taking an initial state, an arbitrary Serializable
event/message and performing an action in the Process
monad that evaluates
to a new state.
Synopsis
- data EventManager
- start :: Process EventManager
- startSupervised :: SupervisorPid -> Process EventManager
- startSupervisedRef :: SupervisorPid -> Process (ProcessId, Message)
- notify :: Serializable a => EventManager -> a -> Process ()
- addHandler :: forall s a. Serializable a => EventManager -> (s -> a -> Process s) -> Process s -> Process ProcessId
- addMessageHandler :: forall s. EventManager -> (s -> Message -> Process (Maybe s)) -> Process s -> Process ProcessId
Documentation
data EventManager Source #
Opaque handle to an Event Manager.
Instances
Generic EventManager Source # | |
Defined in Control.Distributed.Process.Execution.EventManager Associated Types type Rep EventManager :: Type -> Type # | |
Binary EventManager Source # | |
Resolvable EventManager Source # | |
Defined in Control.Distributed.Process.Execution.EventManager | |
type Rep EventManager Source # | |
Defined in Control.Distributed.Process.Execution.EventManager type Rep EventManager = D1 ('MetaData "EventManager" "Control.Distributed.Process.Execution.EventManager" "distributed-process-execution-0.1.5.0-BirXx8fDvtX9c4aBiRno2u" 'True) (C1 ('MetaCons "EventManager" 'PrefixI 'True) (S1 ('MetaSel ('Just "ex") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Exchange))) |
start :: Process EventManager Source #
Start a new Event Manager process and return an opaque handle to it.
notify :: Serializable a => EventManager -> a -> Process () Source #
Broadcast an event to all registered handlers.
addHandler :: forall s a. Serializable a => EventManager -> (s -> a -> Process s) -> Process s -> Process ProcessId Source #
Add a new event handler. The handler runs in its own process, which is spawned locally on behalf of the caller.
addMessageHandler :: forall s. EventManager -> (s -> Message -> Process (Maybe s)) -> Process s -> Process ProcessId Source #
As addHandler
, but operates over a raw Control.Distributed.Process.Message
.