@@ -19,6 +19,7 @@ module Control.Distributed.Process.Internal.Closure.BuiltIn
20 , cpUnlink
20 , cpUnlink
22 , cpExpect
23 , cpExpect
23 , cpNewChan
24 , cpNewChan
24 -- * Support for some CH operations
25 -- * Support for some CH operations
@@ -59,6 +60,7 @@ import Control.Distributed.Process.Internal.Primitives
63 , unmonitor
65 , unmonitor
@@ -83,6 +85,7 @@ remoteTable =
83 . registerStatic "$link" (toDynamic link)
85 . registerStatic "$link" (toDynamic link)
84 . registerStatic "$unlink" (toDynamic unlink)
86 . registerStatic "$unlink" (toDynamic unlink)
85 . registerStatic "$sendDict" (toDynamic (sendDict :: SerializableDict ANY -> ProcessId -> ANY -> Process ()))
87 . registerStatic "$sendDict" (toDynamic (sendDict :: SerializableDict ANY -> ProcessId -> ANY -> Process ()))
88+ . registerStatic "$sendChanDict" (toDynamic (sendChanDict :: SerializableDict ANY -> (SendPort ANY) -> ANY -> Process ()))
86 . registerStatic "$expectDict" (toDynamic (expectDict :: SerializableDict ANY -> Process ANY))
89 . registerStatic "$expectDict" (toDynamic (expectDict :: SerializableDict ANY -> Process ANY))
87 . registerStatic "$newChanDict" (toDynamic (newChanDict :: SerializableDict ANY -> Process (SendPort ANY, ReceivePort ANY)))
90 . registerStatic "$newChanDict" (toDynamic (newChanDict :: SerializableDict ANY -> Process (SendPort ANY, ReceivePort ANY)))
88 . registerStatic "$cpSplit" (toDynamic (cpSplit :: (ANY1 -> Process ANY3) -> (ANY2 -> Process ANY4) -> (ANY1, ANY2) -> Process (ANY3, ANY4)))
91 . registerStatic "$cpSplit" (toDynamic (cpSplit :: (ANY1 -> Process ANY3) -> (ANY2 -> Process ANY4) -> (ANY1, ANY2) -> Process (ANY3, ANY4)))
@@ -98,6 +101,12 @@ remoteTable =
98 sendDict :: forall a. SerializableDict a -> ProcessId -> a -> Process ()
101 sendDict :: forall a. SerializableDict a -> ProcessId -> a -> Process ()
99 sendDict SerializableDict = send
102 sendDict SerializableDict = send
104+ sendChanDict :: forall a . SerializableDict a
108+ sendChanDict SerializableDict = sendChan
101 expectDict :: forall a. SerializableDict a -> Process a
110 expectDict :: forall a. SerializableDict a -> Process a
102 expectDict SerializableDict = expect
111 expectDict SerializableDict = expect
@@ -201,6 +210,9 @@ bindCP x f = bindProcessStatic `closureApplyStatic` x `closureApply` f
201decodeProcessIdStatic :: Static (ByteString -> ProcessId)
210decodeProcessIdStatic :: Static (ByteString -> ProcessId)
202decodeProcessIdStatic = staticLabel "$decodeProcessId"
211decodeProcessIdStatic = staticLabel "$decodeProcessId"
213+decodeSendPortStatic :: forall a . Typeable a => Static (ByteString -> SendPort a)
214+decodeSendPortStatic = staticLabel "$sdictSendPort_"
204-- | 'CP' version of 'link'
216-- | 'CP' version of 'link'
205cpLink :: ProcessId -> Closure (Process ())
217cpLink :: ProcessId -> Closure (Process ())
206cpLink = closure (linkStatic `staticCompose` decodeProcessIdStatic) . encode
218cpLink = closure (linkStatic `staticCompose` decodeProcessIdStatic) . encode
@@ -229,6 +241,19 @@ cpSend dict pid = closure decoder (encode pid)
229 => Static (SerializableDict a -> ProcessId -> a -> Process ())
241 => Static (SerializableDict a -> ProcessId -> a -> Process ())
230 sendDictStatic = staticLabel "$sendDict"
242 sendDictStatic = staticLabel "$sendDict"
244+cpSendChan :: forall a. Typeable a
245+ => Static (SerializableDict a) -> SendPort a -> CP a ()
246+cpSendChan dict sp = closure decoder (encode sp)
248+ decoder :: Static (ByteString -> a -> Process ())
249+ decoder = (sendChanDictStatic `staticApply` dict)
251+ decodeSendPortStatic
253+ sendChanDictStatic :: Typeable a
254+ => Static (SerializableDict a -> SendPort a -> a -> Process ())
255+ sendChanDictStatic = staticLabel "$sendChanDict"
232-- | 'CP' version of 'expect'
257-- | 'CP' version of 'expect'
233cpExpect :: Typeable a => Static (SerializableDict a) -> Closure (Process a)
258cpExpect :: Typeable a => Static (SerializableDict a) -> Closure (Process a)
234cpExpect dict = staticClosure (expectDictStatic `staticApply` dict)
259cpExpect dict = staticClosure (expectDictStatic `staticApply` dict)