theatre-1: Minimalistic actor library

Safe HaskellNone
LanguageHaskell2010

Theatre

Contents

Description

Minimalistic actor library.

Synopsis

Documentation

data Actor message Source #

Actor, which processes the messages of type message.

An abstraction over the message channel, thread-forking and killing.

Instances

Divisible Actor Source # 

Methods

divide :: (a -> (b, c)) -> Actor b -> Actor c -> Actor a #

conquer :: Actor a #

Decidable Actor Source # 

Methods

lose :: (a -> Void) -> Actor a #

choose :: (a -> Either b c) -> Actor b -> Actor c -> Actor a #

Contravariant Actor Source # 

Methods

contramap :: (a -> b) -> Actor b -> Actor a #

(>$) :: b -> Actor b -> Actor a #

Semigroup (Actor message) Source # 

Methods

(<>) :: Actor message -> Actor message -> Actor message #

sconcat :: NonEmpty (Actor message) -> Actor message #

stimes :: Integral b => b -> Actor message -> Actor message #

Monoid (Actor message) Source # 

Methods

mempty :: Actor message #

mappend :: Actor message -> Actor message -> Actor message #

mconcat :: [Actor message] -> Actor message #

Construction

graceful Source #

Arguments

:: (message -> IO ())

Interpreter of a message

-> IO (Actor message) 

An actor which cannot die by itself unless explicitly killed.

Given an interpreter of messages, 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.

disgraceful Source #

Arguments

:: (message -> IO ())

Interpreter of a message

-> IO (Actor message) 

An actor which cannot die by itself unless explicitly killed.

Given an interpreter of messages, forks a thread to run the computation on and produces a handle to address that actor.

suicidal Source #

Arguments

:: (IO message -> IO ())

A message receiver loop. When the loop exits, the actor dies

-> IO (Actor message) 

An actor, whose interpreter can decide that the actor should die.

Given an implementation of a receiver loop of messages, forks a thread to run that receiver on and produces a handle to address that actor.

Usage

tell :: Actor message -> message -> IO () Source #

Send a message to the actor

kill :: Actor message -> IO () Source #

Kill the actor