Example
module Demo.Sup (start) where
import Prelude
import Demo.Event as Event
import Demo.Server as Server
import Demo.FSM.PushButton as FSM
import Control.Behaviour.Supervisor
( Init
, initOk
, Strategy(..)
, childSpec
, startSupWith
)
name :: Atom
name = :sup
start :: Process Pid
start = startSupWith name init
init :: Init
init = initOk (OneForOne, 10, 100)
[ childSpec "Demo.Event" Event.start
, childSpec "Demo.Server" Server.start
, childSpec "Demo.Statem" FSM.start
]
Start a Supervisor process
-- Start a supervisor process.
startSup :: Init -> Process Pid
-- Start a supervisor with name.
startSupWith :: Name -> Init -> Process Pid
Init callback
type SupFlags = (Strategy, Intensity, Integer)
-- | Init Result
data InitResult
= InitOk SupFlags [ChildSpec]
-- ^ {ok, State}
| InitIgnore
-- ^ ignore
-- | Init callback
type Init = Process InitResult
Restart Strategy
data Strategy
= OneForAll
-- ^ Restart all child processes if one terminated.
| OneForOne
-- ^ Restart only the child processs terminated.
| RestForOne
-- ^ TODO: comment...
| SimpleOneForOne
-- ^ TODO: comment...
OneForOne
OneForAll
OneForRest
SimpleOneForOne
当前内容版权归 hamler-lang 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 hamler-lang .