summaryrefslogtreecommitdiff
path: root/testsuite/tests/parallel/test_c_thread_register.ml
blob: 352424a37713eccfeeff91d9f8ed0a696f64d091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(* TEST
   modules = "test_c_thread_register_cstubs.c"
   * hassysthreads
   include systhreads
   ** bytecode
   ** native
*)

(* spins a external thread from C and register it to the OCaml runtime *)

external spawn_thread : (unit -> unit) -> unit = "spawn_thread"

let passed () = Printf.printf "passed\n"

let _ =
  let d =
    Domain.spawn begin fun () ->
      spawn_thread passed;
      Thread.delay 0.5
    end
  in
  let t = Thread.create (fun () -> Thread.delay 1.0) () in
  Thread.join t;
  Domain.join d