@@ -27,35 +27,53 @@ let rec run_fiber ?(max_domains = 1) ?(allow_lwt = true) ?fatal_exn_handler
27
27
| _ -> `Lwt
28
28
in
29
29
let n_domains = Int. min max_domains (Domain. recommended_domain_count () ) in
30
- ignore
31
- (match scheduler with
32
- | `Fifos -> " fifos"
33
- | `Multififos -> " multififos"
34
- | `Randos -> " randos"
35
- | `Lwt -> " lwt" );
36
- match scheduler with
37
- | `Lwt ->
38
- if Picos_thread. is_main_thread () && allow_lwt then begin
39
- let old_hook = ! Lwt. async_exception_hook in
40
- begin
41
- match fatal_exn_handler with
42
- | None -> ()
43
- | Some hook -> Lwt. async_exception_hook := hook
44
- end ;
45
- match Lwt_main. run (Picos_lwt_unix. run_fiber fiber main) with
46
- | result ->
47
- Lwt. async_exception_hook := old_hook;
48
- result
49
- | exception exn ->
50
- Lwt. async_exception_hook := old_hook;
51
- raise exn
52
- end
53
- else run_fiber ~max_domains ~allow_lwt fiber main
54
- | `Randos ->
55
- Picos_randos. run_fiber_on ?fatal_exn_handler ~n_domains fiber main
56
- | `Fifos -> Picos_fifos. run_fiber ?fatal_exn_handler fiber main
57
- | `Multififos ->
58
- Picos_multififos. run_fiber_on ?fatal_exn_handler ~n_domains fiber main
30
+ let quota = 1 + Random. int 100 in
31
+ match
32
+ match scheduler with
33
+ | `Lwt ->
34
+ if Picos_thread. is_main_thread () && allow_lwt then
35
+ Some
36
+ (fun () ->
37
+ let old_hook = ! Lwt. async_exception_hook in
38
+ begin
39
+ match fatal_exn_handler with
40
+ | None -> ()
41
+ | Some hook -> Lwt. async_exception_hook := hook
42
+ end ;
43
+ match Lwt_main. run (Picos_lwt_unix. run_fiber fiber main) with
44
+ | result ->
45
+ Lwt. async_exception_hook := old_hook;
46
+ result
47
+ | exception exn ->
48
+ Lwt. async_exception_hook := old_hook;
49
+ raise exn )
50
+ else None
51
+ | `Randos ->
52
+ Some
53
+ (fun () ->
54
+ Picos_randos. run_fiber_on ?fatal_exn_handler ~n_domains fiber main)
55
+ | `Fifos ->
56
+ Some
57
+ (fun () -> Picos_fifos. run_fiber ~quota ?fatal_exn_handler fiber main)
58
+ | `Multififos ->
59
+ Some
60
+ (fun () ->
61
+ Picos_multififos. run_fiber_on ~quota ?fatal_exn_handler ~n_domains
62
+ fiber main)
63
+ with
64
+ | None -> run_fiber ~max_domains ~allow_lwt ?fatal_exn_handler fiber main
65
+ | Some run -> begin
66
+ try run ()
67
+ with exn ->
68
+ Printf. printf " Test_scheduler: %s ~quota:%d ~n_domains:%d\n %!"
69
+ (match scheduler with
70
+ | `Fifos -> " fifos"
71
+ | `Multififos -> " multififos"
72
+ | `Randos -> " randos"
73
+ | `Lwt -> " lwt" )
74
+ quota n_domains;
75
+ raise exn
76
+ end
59
77
60
78
let run ?max_domains ?allow_lwt ?fatal_exn_handler ?(forbid = false ) main =
61
79
let computation = Computation. create ~mode: `LIFO () in
0 commit comments