haskell-otp-0.1.0.0: Haskell single-node implementation of Erlang/OTP patterns

Safe HaskellNone
LanguageHaskell2010

Concurrency.OTP.Process

Synopsis

Documentation

data Pid msg Source

Identificator of process accepted messages of type msg

Instances

IsProcess a (Pid a) 
Eq (Pid a) 
Show (Pid a) 

data Process msg a Source

Process computation monad

Instances

data Reason Source

Process termination reason

Constructors

Normal

Caused when process terminate on end of computation or call exit function

Aborted

Caused when process terminate from another process by terminate function

Error String

Caused when process terminate abnormal way and store exception description

Instances

class IsProcess a p | p -> a where Source

Methods

getPid :: p -> Pid a Source

Instances

IsProcess a (Pid a) 

data LinkId Source

Id of subscription on process termination.

Instances

spawn :: Process msg () -> IO (Pid msg) Source

Spawn new process in own thread

linkIO :: IsProcess msg p => p -> (Reason -> IO ()) -> IO LinkId Source

Register callback, which will be called on process termination and return subscription id. If process has died already, callback will be called immediatly.

unlinkIO :: IsProcess msg p => p -> LinkId -> IO () Source

Remove termination callback by LinkId

withLinkIO :: IsProcess msg p => p -> (Reason -> IO ()) -> (LinkId -> IO a) -> IO a Source

Run action in under link bracket.

withLinkIO_ :: IsProcess msg p => p -> (Reason -> IO ()) -> IO a -> IO a Source

link :: IsProcess msg p => p -> Process msg LinkId Source

Link current process with another process p. Current process will be terminated, if process p will be terminated abnormal.

send :: Pid msg -> msg -> Process a () Source

Send messages from one process to another

sendIO :: Pid msg -> msg -> IO () Source

Asynchronious send messages of type msg to process

receive :: MonadProcess msg m => m msg Source

Get message from process mailbox. Blocked, if mailbox is empty, until message will be received.

receiveWithTimeout :: MonadProcess msg m => Maybe Int -> m (Maybe msg) Source

Get message from process mailbox with timeout in milliseconds. Blocked, if mailbox is empty, until message will be received or timeout will be expired.

self :: MonadProcess msg m => m (Pid msg) Source

Return pid of current process

exit :: MonadProcess msg m => m () Source

Terminate current process with Normal reason.

terminate :: IsProcess msg p => p -> IO () Source

Terminate process p

isAlive :: IsProcess msg p => p -> IO Bool Source

Check what process p is alive

wait :: IsProcess msg p => p -> IO () Source

Block current execution thread until process is alive.

liftIO :: MonadIO m => forall a. IO a -> m a

Lift a computation from the IO monad.