Debian Codegraph @

doc/guide/src/ConcurrentML.adoc

raw
1 = ConcurrentML
2
3 http://cml.cs.uchicago.edu/[Concurrent ML] is an SML concurrency
4 library based on synchronous message passing. MLton has an initial
5 port of CML from SML/NJ, but is missing a thread-safe wrapper around
6 the Basis Library and event-based equivalents to `IO` and `OS`
7 functions.
8
9 All of the core CML functionality is present.
10
11 [source,sml]
12 ----
13 structure CML: CML
14 structure SyncVar: SYNC_VAR
15 structure Mailbox: MAILBOX
16 structure Multicast: MULTICAST
17 structure SimpleRPC: SIMPLE_RPC
18 structure RunCML: RUN_CML
19 ----
20
21 The `RUN_CML` signature is minimal.
22
23 [source,sml]
24 ----
25 signature RUN_CML =
26 sig
27 val isRunning: unit -> bool
28 val doit: (unit -> unit) * Time.time option -> OS.Process.status
29 val shutdown: OS.Process.status -> 'a
30 end
31 ----
32
33 MLton's `RunCML` structure does not include all of the cleanup and
34 logging operations of SML/NJ's `RunCML` structure. However, the
35 implementation does include the `CML.timeOutEvt` and `CML.atTimeEvt`
36 functions, and a preemptive scheduler that knows to sleep when there
37 are no ready threads and some threads blocked on time events.
38
39 Because MLton does not wrap the Basis Library for CML, the "right" way
40 to call a Basis Library function that is stateful is to wrap the call
41 with `MLton.Thread.atomically`.
42
43 == Usage
44
45 * You can import the CML Library into an MLB file with:
46 +
47 [options="header"]
48 |===
49 |MLB file|Description
50 |`$(SML_LIB)/cml/cml.mlb`|
51 |===
52
53 * If you are porting a project from SML/NJ's <<CompilationManager#>> to
54 MLton's <<MLBasis#,ML Basis system>> using `cm2mlb`, note that the
55 following map is included by default:
56 +
57 ----
58 # CML Library
59 $cml $(SML_LIB)/cml
60 $cml/cml.cm $(SML_LIB)/cml/cml.mlb
61 ----
62 +
63 This will automatically convert a `$cml/cml.cm` import in an input `.cm` file into a `$(SML_LIB)/cml/cml.mlb` import in the output `.mlb` file.
64
65 == Also see
66
67 * <<ConcurrentMLImplementation#>>
68 * <<eXene#>>