module Control.Distributed.Process.Internal.Closure.BuiltIn
(
remoteTable
, serializableDictUnit
, linkClosure
, unlinkClosure
, sendClosure
, returnClosure
, expectClosure
) where
import Data.Binary (encode)
import Data.Typeable (typeOf)
import Control.Distributed.Process.Internal.Primitives (link, unlink)
import Control.Distributed.Process.Internal.Types
( ProcessId
, Closure
, Process
, RemoteTable
, SerializableDict(..)
, Closure(..)
, Static(..)
, StaticLabel(..)
)
import Control.Distributed.Process.Internal.Closure.TH (remotable, mkClosure)
import Control.Distributed.Process.Internal.TypeRep ()
serializableDictUnit :: SerializableDict ()
serializableDictUnit = SerializableDict
remotable ['link, 'unlink, 'serializableDictUnit]
remoteTable :: RemoteTable -> RemoteTable
remoteTable = __remoteTable
linkClosure :: ProcessId -> Closure (Process ())
linkClosure = $(mkClosure 'link)
unlinkClosure :: ProcessId -> Closure (Process ())
unlinkClosure = $(mkClosure 'unlink)
sendClosure :: forall a. SerializableDict a -> ProcessId -> Closure (a -> Process ())
sendClosure SerializableDict pid =
Closure (Static ClosureSend) (encode (typeOf (undefined :: a), pid))
returnClosure :: forall a. SerializableDict a -> a -> Closure (Process a)
returnClosure SerializableDict val =
Closure (Static ClosureReturn) (encode (typeOf (undefined :: a), encode val))
expectClosure :: forall a. SerializableDict a -> Closure (Process a)
expectClosure SerializableDict =
Closure (Static ClosureExpect) (encode (typeOf (undefined :: a)))