distributed-process-client-server-0.2.7.1: The Cloud Haskell Application Platform
Copyright(c) Tim Watson 2012 - 2017
LicenseBSD3 (see the file LICENSE)
MaintainerTim Watson <watson.timothy@gmail.com>
Stabilityexperimental
Portabilitynon-portable (requires concurrency)
Safe HaskellNone
LanguageHaskell2010

Control.Distributed.Process.ManagedProcess.Server.Gen

Description

The Server Portion of the Managed Process API, as presented by the GenProcess monad. These functions are generally intended for internal use, but the API is relatively stable and therefore they have been re-exported here for general use. Note that if you modify a process' internal state (especially that of the internal priority queue) then you are responsible for any alteratoin that makes to the semantics of your processes behaviour.

See Control.Distributed.Process.ManagedProcess.Internal.GenProcess

Synopsis

Server actions

reply :: Serializable r => r -> GenProcess s (ProcessReply r s) Source #

Instructs the process to send a reply and continue running.

replyWith :: Serializable r => r -> ProcessAction s -> GenProcess s (ProcessReply r s) Source #

Instructs the process to send a reply and evaluate the ProcessAction.

noReply :: Serializable r => ProcessAction s -> GenProcess s (ProcessReply r s) Source #

Instructs the process to skip sending a reply and evaluate a ProcessAction

continue :: GenProcess s (ProcessAction s) Source #

Instructs the process to continue running and receiving messages.

timeoutAfter :: Delay -> GenProcess s (ProcessAction s) Source #

Instructs the process loop to wait for incoming messages until Delay is exceeded. If no messages are handled during this period, the timeout handler will be called. Note that this alters the process timeout permanently such that the given Delay will remain in use until changed.

Note that timeoutAfter NoDelay will cause the timeout handler to execute immediately if no messages are present in the process' mailbox.

hibernate :: TimeInterval -> GenProcess s (ProcessAction s) Source #

Instructs the process to hibernate for the given TimeInterval. Note that no messages will be removed from the mailbox until after hibernation has ceased. This is equivalent to calling threadDelay.

stop :: ExitReason -> GenProcess s (ProcessAction s) Source #

Instructs the process to terminate, giving the supplied reason. If a valid shutdownHandler is installed, it will be called with the ExitReason returned from this call, along with the process state.

reject :: forall r s. String -> GenProcess s (ProcessReply r s) Source #

Reject the message we're currently handling.

rejectWith :: forall r m s. Show r => r -> GenProcess s (ProcessReply m s) Source #

Reject the message we're currently handling, giving an explicit reason.

become :: ProcessDefinition s -> GenProcess s (ProcessAction s) Source #

The server loop will execute against the supplied ProcessDefinition, allowing the process to change its behaviour (in terms of message handlers, exit handling, termination, unhandled message policy, etc)

haltNoReply :: forall s r. Serializable r => ExitReason -> GenProcess s (ProcessReply r s) Source #

Halt process execution during a call handler, without paying any attention to the expected return type.

lift :: Process a -> GenProcess s a Source #

Lift an action in the Process monad to GenProcess.

recvLoop :: ProcessDefinition s -> s -> Delay -> Process ExitReason Source #

Managed process loop.

Evaluating this function will cause the caller to enter a server loop, constantly reading messages from its mailbox (and/or other supplied control planes) and passing these to handler functions in the supplied process definition. Only when it is determined that the server process should terminate - either by the handlers deciding to stop the process, or by an unhandled exit signal or other form of failure condition (e.g. synchronous or asynchronous exceptions).

precvLoop :: PrioritisedProcessDefinition s -> s -> Delay -> Process ExitReason Source #

Prioritised process loop.

Evaluating this function will cause the caller to enter a server loop, constantly reading messages from its mailbox (and/or other supplied control planes) and passing these to handler functions in the supplied process definition. Only when it is determined that the server process should terminate - either by the handlers deciding to stop the process, or by an unhandled exit signal or other form of failure condition (e.g. synchronous or asynchronous exceptions).

ensureIOManagerIsRunning before evaluating this loop...

currentTimeout :: GenProcess s Delay Source #

The current (user supplied) timeout.

systemTimeout :: GenProcess s Timer Source #

The Timer for the system timeout. See drainTimeout.

drainTimeout :: GenProcess s Delay Source #

The Delay for the drainTimeout.

processState :: GenProcess s s Source #

Evaluates to the user defined state for the currently executing server loop.

processDefinition :: GenProcess s (ProcessDefinition s) Source #

The ProcessDefinition for the current loop.

processFilters :: GenProcess s [DispatchFilter s] Source #

The list of filters for the current loop.

processUnhandledMsgPolicy :: GenProcess s UnhandledMessagePolicy Source #

Evaluates to the UnhandledMessagePolicy for the current loop.

processQueue :: GenProcess s [Message] Source #

Returns a read only view on the internal priority queue.

gets :: (ProcessState s -> a) -> GenProcess s a Source #

Evaluate the given function over the ProcessState s for the caller, and return the result.

getAndModifyState :: (ProcessState s -> (ProcessState s, a)) -> GenProcess s a Source #

Modify our state and return a value (potentially from it).

modifyState :: (ProcessState s -> ProcessState s) -> GenProcess s () Source #

Modify our state.

setUserTimeout :: Delay -> GenProcess s () Source #

Set the user timeout applied whilst a prioritised process loop is in a blocking receive.

setProcessState :: s -> GenProcess s () Source #

Set the current process state.

data GenProcess s a Source #

StateT based monad for prioritised process loops.

Instances

Instances details
MonadFix (GenProcess s) Source # 
Instance details

Defined in Control.Distributed.Process.ManagedProcess.Internal.Types

Methods

mfix :: (a -> GenProcess s a) -> GenProcess s a #

MonadIO (GenProcess s) Source # 
Instance details

Defined in Control.Distributed.Process.ManagedProcess.Internal.Types

Methods

liftIO :: IO a -> GenProcess s a #

Applicative (GenProcess s) Source # 
Instance details

Defined in Control.Distributed.Process.ManagedProcess.Internal.Types

Methods

pure :: a -> GenProcess s a #

(<*>) :: GenProcess s (a -> b) -> GenProcess s a -> GenProcess s b #

liftA2 :: (a -> b -> c) -> GenProcess s a -> GenProcess s b -> GenProcess s c #

(*>) :: GenProcess s a -> GenProcess s b -> GenProcess s b #

(<*) :: GenProcess s a -> GenProcess s b -> GenProcess s a #

Functor (GenProcess s) Source # 
Instance details

Defined in Control.Distributed.Process.ManagedProcess.Internal.Types

Methods

fmap :: (a -> b) -> GenProcess s a -> GenProcess s b #

(<$) :: a -> GenProcess s b -> GenProcess s a #

Monad (GenProcess s) Source # 
Instance details

Defined in Control.Distributed.Process.ManagedProcess.Internal.Types

Methods

(>>=) :: GenProcess s a -> (a -> GenProcess s b) -> GenProcess s b #

(>>) :: GenProcess s a -> GenProcess s b -> GenProcess s b #

return :: a -> GenProcess s a #

MonadCatch (