Import Upstream version 20180207
[hcoop/debian/mlton.git] / regression / thread-switch-size.sml
CommitLineData
7f918cf1
CE
1(* Access the current stack in the heap via a MLton.size object trace. *)
2val rt : MLton.Thread.Runnable.t option ref = ref NONE
3val rs : int ref = ref 0
4
5fun stats () =
6 let
7 val () = rs := MLton.size rt
8 in
9 ()
10 end
11
12fun switcheroo () =
13 MLton.Thread.switch
14 (fn t => let
15 val () = rt := SOME (MLton.Thread.prepare (t, ()))
16 val () = stats ()
17 in
18 valOf (!rt)
19 end)
20
21val () = switcheroo ()
22val _ = print (concat ["!rs > 0 = ", Bool.toString (!rs > 0), "\n"])