Skip to content

Commit 9969da1

Browse files
committed
Excise the concept of RemoteTable to lean into static pointers
1 parent aea7740 commit 9969da1

73 files changed

Lines changed: 863 additions & 1796 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/distributed-process-async/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Unreleased
2+
3+
* Breaking: `remoteTask` takes a `Closure (SerializableDict a)` instead of a `Static (SerializableDict a)`.
4+
15
2025-02-04 Laurent P. René de Cotret <laurent.decotret@outlook.com> 0.2.11
26

37
* Ported test suite to use `tasty` rather than `test-framework`.

‎packages/distributed-process-async/distributed-process-async.cabal‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: distributed-process-async
3-
version: 0.2.11
3+
version: 0.3.0
44
build-type: Simple
55
license: BSD-3-Clause
66
license-file: LICENCE
@@ -38,7 +38,7 @@ library
3838
import: warnings
3939
build-depends:
4040
base >= 4.14 && < 5,
41-
distributed-process >= 0.6.1 && < 0.8,
41+
distributed-process >= 0.8 && < 0.9,
4242
exceptions >= 0.10 && < 1.0,
4343
binary >= 0.8 && < 0.9,
4444
stm >= 2.4 && < 2.6,

‎packages/distributed-process-async/src/Control/Distributed/Process/Async.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ task :: Process a -> AsyncTask a
8080
task = AsyncTask
8181

8282
-- | Wraps the components required and builds a remote 'AsyncTask'.
83-
remoteTask :: Static (SerializableDict a)
83+
remoteTask :: Closure (SerializableDict a)
8484
-> NodeId
8585
-> Closure (Process a)
8686
-> AsyncTask a

‎packages/distributed-process-async/src/Control/Distributed/Process/Async/Internal/Types.hs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE DeriveDataTypeable #-}
2-
{-# LANGUAGE TemplateHaskell #-}
32
{-# LANGUAGE StandaloneDeriving #-}
43
{-# LANGUAGE RankNTypes #-}
54
{-# LANGUAGE ExistentialQuantification #-}
@@ -55,7 +54,7 @@ data AsyncTask a =
5554
asyncTask :: Process a -- ^ the task to be performed
5655
}
5756
| AsyncRemoteTask {
58-
asyncTaskDict :: Static (SerializableDict a)
57+
asyncTaskDict :: Closure (SerializableDict a)
5958
-- ^ the serializable dict required to spawn a remote process
6059
, asyncTaskNode :: NodeId
6160
-- ^ the node on which to spawn the asynchronous task

‎packages/distributed-process-async/tests/TestAsync.hs‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
{-# LANGUAGE StaticPointers #-}
12
{-# LANGUAGE DeriveDataTypeable #-}
2-
{-# LANGUAGE TemplateHaskell #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
44

55
module Main where
@@ -12,7 +12,7 @@ import Control.Distributed.Process.Serializable()
1212
import Control.Distributed.Process.Async
1313
import Control.Distributed.Process.SysTest.Utils
1414
import Control.Monad (replicateM_)
15-
import Data.Binary()
15+
import Data.Binary (decode, encode)
1616
import Data.Typeable()
1717
import Network.Transport.TCP
1818
import qualified Network.Transport as NT
@@ -139,18 +139,15 @@ testAsyncWaitCancelTimeout result = do
139139
p1 <- async $ task expect
140140
waitCancelTimeout 1000000 p1 >>= stash result
141141

142-
remotableDecl [
143-
[d| fib :: (NodeId,Int) -> Process Integer ;
144-
fib (_,0) = return 0
145-
fib (_,1) = return 1
146-
fib (myNode,n) = do
147-
let tsk = remoteTask ($(functionTDict 'fib)) myNode ($(mkClosure 'fib) (myNode,n-2))
148-
future <- async tsk
149-
y <- fib (myNode,n-1)
150-
(AsyncDone z) <- wait future
151-
return $ y + z
152-
|]
153-
]
142+
fib :: (NodeId,Int) -> Process Integer
143+
fib (_,0) = return 0
144+
fib (_,1) = return 1
145+
fib (myNode,n) = do
146+
let tsk = remoteTask (static SerializableDict) myNode (closure (static (fib . decode)) (encode (myNode, n-2)))
147+
future <- async tsk
148+
y <- fib (myNode,n-1)
149+
(AsyncDone z) <- wait future
150+
return $ y + z
154151

155152
-- Tests that wait returns when remote actions complete.
156153
testAsyncRecursive :: TestResult Integer -> Process ()
@@ -212,7 +209,7 @@ tests localNode = testGroup "" [
212209

213210
asyncStmTests :: NT.Transport -> IO TestTree
214211
asyncStmTests transport = do
215-
localNode <- newLocalNode transport $ __remoteTableDecl initRemoteTable
212+
localNode <- newLocalNode transport
216213
let testData = tests localNode
217214
return testData
218215

‎packages/distributed-process-client-server/distributed-process-client-server.cabal‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: distributed-process-client-server
3-
version: 0.2.8.0
3+
version: 0.2.9.0
44
build-type: Simple
55
license: BSD-3-Clause
66
license-file: LICENCE
@@ -39,9 +39,9 @@ library
3939
import: warnings
4040
build-depends:
4141
base >= 4.8.2.0 && < 5,
42-
distributed-process >= 0.6.6 && < 0.8,
43-
distributed-process-extras >= 0.3.1 && < 0.4,
44-
distributed-process-async >= 0.2.4 && < 0.3,
42+
distributed-process >= 0.8 && < 0.9,
43+
distributed-process-extras >= 0.4 && < 0.5,
44+
distributed-process-async >= 0.3 && < 0.4,
4545
binary >= 0.8 && < 0.9,
4646
deepseq >= 1.4 && < 1.7,
4747
mtl,

‎packages/distributed-process-client-server/tests/Counter.hs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE DeriveDataTypeable #-}
22
{-# LANGUAGE DeriveGeneric #-}
3-
{-# LANGUAGE TemplateHaskell #-}
43
{-# LANGUAGE ScopedTypeVariables #-}
54
{-# LANGUAGE BangPatterns #-}
65

‎packages/distributed-process-client-server/tests/SafeCounter.hs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE DeriveDataTypeable #-}
2-
{-# LANGUAGE TemplateHaskell #-}
32
{-# LANGUAGE ScopedTypeVariables #-}
43
{-# LANGUAGE BangPatterns #-}
54
{-# LANGUAGE DeriveGeneric #-}

‎packages/distributed-process-client-server/tests/TestManagedProcess.hs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Control.Exception (SomeException)
1515
import Control.Distributed.Process hiding (call, catch)
1616
import Control.Distributed.Process.Async (AsyncResult(AsyncDone))
1717
import Control.Distributed.Process.Node
18-
import Control.Distributed.Process.Extras hiding (__remoteTable, monitor, send, nsend)
18+
import Control.Distributed.Process.Extras hiding (monitor, send, nsend)
1919
import Control.Distributed.Process.ManagedProcess
2020
import Control.Distributed.Process.SysTest.Utils
2121
import Control.Distributed.Process.Extras.Time
@@ -212,7 +212,7 @@ testCounterExceedsLimit result = do
212212

213213
tests :: NT.Transport -> IO TestTree
214214
tests transport = do
215-
localNode <- newLocalNode transport initRemoteTable
215+
localNode <- newLocalNode transport
216216
scpid <- newEmptyMVar
217217
_ <- forkProcess localNode $ SafeCounter.startCounter 5 >>= stash scpid
218218
safeCounter <- takeMVar scpid

‎packages/distributed-process-client-server/tests/TestPrioritisedProcess.hs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Control.Exception (SomeException)
1515
import Control.DeepSeq (NFData)
1616
import Control.Distributed.Process hiding (call, send, catch, sendChan, wrapMessage)
1717
import Control.Distributed.Process.Node
18-
import Control.Distributed.Process.Extras hiding (__remoteTable, monitor)
18+
import Control.Distributed.Process.Extras hiding (monitor)
1919
import Control.Distributed.Process.Async hiding (check)
2020
import Control.Distributed.Process.ManagedProcess hiding (reject, Message)
2121
import qualified Control.Distributed.Process.ManagedProcess.Server.Priority as P (Message)
@@ -536,7 +536,7 @@ testCallPrioritisation result = do
536536

537537
tests :: NT.Transport -> IO TestTree
538538
tests transport = do
539-
localNode <- newLocalNode transport initRemoteTable
539+
localNode <- newLocalNode transport
540540
return $ testGroup "" [
541541
testGroup "basic server functionality matches un-prioritised processes" [
542542
testCase "basic call with explicit server reply"

0 commit comments

Comments
 (0)