Puneet Varma (Editor)

Concurrent ML

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

Concurrent ML (CML) is a concurrent extension of the Standard ML programming language.

Sample Code

Here is sample code to print "hello, world" to the console. It spawns a thread which creates a channel for strings. This thread then spawns another thread which prints the first string that is received on the channel. The former thread then sends the "hello, world\n" string on the channel. It uses SML/NJ and CML (note that the heap name will be different on non linux-x86 platforms; you may need to change the line with "cml_test.x86-linux" to something different):

cml_test.cm
Library structure Hello is $cml/basis.cm $cml/cml.cm cml_test.sml
cml_test.sml
structure Hello = struct open CML fun hello () = let val c : string chan = channel () in spawn (fn () => TextIO.print (recv c)); send (c, "hello, world\n"); exit () end fun main (name, argv) = RunCML.doit (fn () => ignore (spawn hello), NONE) end
Running

References

Concurrent ML Wikipedia


Similar Topics