Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / cml / tests / timeout.sml
CommitLineData
7f918cf1
CE
1
2structure Main =
3struct
4 open CML
5
6 val print = TextIO.print
7
8 fun doit' n =
9 RunCML.doit
10 (fn () =>
11 let
12 fun make m () =
13 (print (concat ["make: ", Int.toString m, " ",
14 tidToString (getTid ()), "\n"])
15 ; sync (timeOutEvt (Time.fromSeconds (Int.toLarge m)))
16 ; print (concat ["finish: ", Int.toString m, " ",
17 tidToString (getTid ()), "\n"]))
18 fun loop m =
19 if m <= 0
20 then ()
21 else let
22 val _ = spawn (make m)
23 in
24 loop (m - 10)
25 end
26 in
27 loop n
28 end,
29 SOME (Time.fromMilliseconds 10))
30
31 fun doit n =
32 let
33 val x = doit' n
34 in
35 x
36 end
37end