signature MLTON_WORLD = sig datatype status = Clone | Original val load: string -> 'a val save: string -> status val saveThread: string * Thread.Runnable.t -> unit end
-
datatype status
-
load f
-
save f
-
saveThread (f, rt)
-
specifies whether a world is original or restarted (a clone).
-
loads the saved computation from file f.
-
saves the entire state of the computation to the file f. The computation can then be restarted at a later time using World.load or the load-world runtime option. The call to save in the original computation returns Original and the call in the restarted world returns Clone.
-
saves the entire state of the computation to the file f that will resume with thread rt upon restart.
Example
Suppose that save-world.sml contains the following.
open MLton.World val _ = case save "world" of Original => print "I am the original\n" | Clone => print "I am the clone\n"
Then, if we compile save-world.sml and run it, the Original branch will execute, and a file named world will be created.
% mlton save-world.sml % save-world I am the original
We can then load world using the load-world run time option.
% save-world @MLton load-world world -- I am the clone