Skip to content

Commit 49aef21

Browse files
author
Tim Watson
committed
add to the managed process tutorial
1 parent 3e9e4fe commit 49aef21

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

tutorials/3.managedprocess.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ In order to explore the `ManagedProcess` API, we will present a simple
1010
example taken from the test suite, which exercises some of the more
1111
interesting features.
1212

13+
The main idea behind `ManagedProcess` is to separate the functional
14+
and non-functional aspects of a process. By functional, we mean whatever
15+
application specific task the process performs, and by non-functional
16+
we mean the *concurrency* or, more precisely, handling of the process'
17+
mailbox.
18+
1319
Let's imagine we want to execute tasks on an arbitrary node, using a
1420
mechanism much as we would with the `call` API from distributed-process.
1521
As with `call`, we want the caller to block whilst the remote task is
@@ -29,4 +35,21 @@ from the backlog and executed.
2935
such as this, based on the synchronous `call` and asynchronous `cast`
3036
functions. Although `call` is synchronous, communication with the
3137
*server process* is out of band, both from the client and the server's
32-
point of view.
38+
point of view. The server implementation chooses whether to reply to
39+
a call request immediately, or defer its reply until a later stage
40+
and go back to receiving messages in the meanwhile.
41+
42+
### Implementation Sketch
43+
44+
We start out with some types: the tasks we perform and the maximum
45+
pool size:
46+
47+
{% highlight haskell %}
48+
type PoolSize = Int
49+
type SimpleTask a = Closure (Process a)
50+
{% endhighlight %}
51+
52+
To submit a task, our clients will submit an action in the process
53+
monad, wrapped in a `Closure` environment. We will use the `Addressable`
54+
typeclass to allow clients to specify the server's location in whatever
55+
manner suits them.

0 commit comments

Comments
 (0)