Packages

The Phi Programming Language

Current section

Files

Jump to
phi priv Control Distributed Global.phi
Raw

priv/Control/Distributed/Global.phi

-----------------------------------------------------------------------------
-- |
-- Module : Control.Distributed.Global
-- Copyright : (c) 2020-2021 EMQ Technologies Co., Ltd.
-- License : BSD-style (see the LICENSE file)
--
-- Maintainer : Feng Lee, feng@emqx.io
-- Yang M, yangm@emqx.io
-- Stability : experimental
-- Portability : portable
--
-- The Global name registration module.
--
-----------------------------------------------------------------------------
module Control.Distributed.Global where
import Control.Distributed.Node (Node)
import Control.Monad (IO)
import Control.Process (Process)
import Data.Maybe (Maybe)
import Data.Pid (Pid)
import Data.Unit (Unit)
type Name = Atom
type ResourceId = Atom
type LockRequesterPid = Pid
type Resolve = (Name -> Pid -> Pid -> Maybe Pid)
type LockId = (ResourceId, LockRequesterPid)
foreign import delLock :: LockId -> Process ()
foreign import delLockAt :: LockId -> [Node] -> Process ()
foreign import notifyAllName :: Name -> Pid -> Pid -> Process ()
foreign import randomExitName :: Name -> Pid -> Pid -> Process ()
foreign import randomNotifyName :: Name -> Pid -> Pid -> Process ()
foreign import registerName :: Name -> Pid -> Process Boolean
foreign import registerNameWith :: Name -> Pid -> Resolve -> Process Boolean
foreign import reRegisterName :: Name -> Pid -> Process Boolean
foreign import reRegisterNameWith :: Name -> Pid -> Resolve -> Process Boolean
foreign import registeredNames :: Process [Name]
foreign import send :: forall m. Name -> m -> Process Pid
foreign import setLock :: LockId -> Process Boolean
foreign import setLockAt :: LockId -> [Node] -> Process Boolean
foreign import setLockRetriesAt :: LockId -> [Node] -> Integer -> Process Boolean
foreign import sync :: Process ()
foreign import trans :: forall res. LockId -> IO () -> Process res
foreign import transAt :: forall res. LockId -> IO () -> [Node] -> Process res
foreign import transRetriesAt :: forall res. LockId -> IO () -> [Node] -> Process res
foreign import unregisterName :: Name -> Process ()
foreign import whereisName :: Name -> Process (Maybe Pid)