summaryrefslogtreecommitdiff
path: root/testsuite/tests/parallel/poll.ml
blob: e0774ec64228937a2eb1165fd3489a99daf0482a (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
25
26
27
28
29
30
(* TEST
 include unix;
 hasunix;
 {
   bytecode;
 }{
   native;
 }
*)

let continue = Atomic.make true

let rec loop () =
  if Atomic.get continue then loop ()

let rec repeat f = function
  | 0 -> ()
  | n -> f (); repeat f (n - 1)

let f () =
  Atomic.set continue true;
  let d = Domain.spawn loop in
  Unix.sleepf 5E-2;
  Gc.full_major();
  Atomic.set continue false;
  Domain.join d

let _ =
  repeat f 10 ;
  print_endline "OK"