Import Upstream version 20180207
[hcoop/debian/mlton.git] / regression / thread-switch-size.sml
1 (* Access the current stack in the heap via a MLton.size object trace. *)
2 val rt : MLton.Thread.Runnable.t option ref = ref NONE
3 val rs : int ref = ref 0
4
5 fun stats () =
6 let
7 val () = rs := MLton.size rt
8 in
9 ()
10 end
11
12 fun 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
21 val () = switcheroo ()
22 val _ = print (concat ["!rs > 0 = ", Bool.toString (!rs > 0), "\n"])