@@ -26,7 +26,28 @@ let init () =
2626 propagate ()
2727 end
2828
29- let rec run_fiber ?(max_domains = 1 ) ?(allow_lwt = true )
29+ let explain scheduler ~quota ~n_domains =
30+ let quota =
31+ match scheduler with
32+ | `Fifos | `Multififos -> Printf. sprintf " ~quota:%d" quota
33+ | `Randos | `Thread | `Lwt -> " "
34+ in
35+ let n_domains =
36+ match scheduler with
37+ | `Multififos | `Randos -> Printf. sprintf " ~n_domains:%d" n_domains
38+ | `Fifos | `Thread | `Lwt -> " "
39+ in
40+ let scheduler =
41+ match scheduler with
42+ | `Fifos -> " fifos"
43+ | `Multififos -> " multififos"
44+ | `Randos -> " randos"
45+ | `Thread -> " thread"
46+ | `Lwt -> " lwt"
47+ in
48+ Printf. printf " Testing with scheduler: %s%s%s\n %!" scheduler quota n_domains
49+
50+ let rec run_fiber ?(verbose = false ) ?(max_domains = 1 ) ?(allow_lwt = true )
3051 ?(avoid_threads = false ) ?fatal_exn_handler fiber main =
3152 init () ;
3253 let scheduler =
@@ -80,26 +101,21 @@ let rec run_fiber ?(max_domains = 1) ?(allow_lwt = true)
80101 (fun () -> Picos_mux_thread. run_fiber ?fatal_exn_handler fiber main)
81102 with
82103 | None ->
83- run_fiber ~max_domains ~allow_lwt ~avoid_threads ?fatal_exn_handler fiber
84- main
104+ run_fiber ~verbose ~ max_domains ~allow_lwt ~avoid_threads
105+ ?fatal_exn_handler fiber main
85106 | Some run -> begin
107+ if verbose then explain scheduler ~quota ~n_domains ;
86108 try run ()
87109 with exn ->
88- Printf. printf " Test_scheduler: %s ~quota:%d ~n_domains:%d\n %!"
89- (match scheduler with
90- | `Fifos -> " fifos"
91- | `Multififos -> " multififos"
92- | `Randos -> " randos"
93- | `Thread -> " thread"
94- | `Lwt -> " lwt" )
95- quota n_domains;
110+ if not verbose then explain scheduler ~quota ~n_domains ;
96111 raise exn
97112 end
98113
99- let run ?max_domains ?allow_lwt ?avoid_threads ?fatal_exn_handler
114+ let run ?verbose ? max_domains ?allow_lwt ?avoid_threads ?fatal_exn_handler
100115 ?(forbid = false ) main =
101116 let computation = Computation. create ~mode: `LIFO () in
102117 let fiber = Fiber. create ~forbid computation in
103118 let main _ = Computation. capture computation main () in
104- run_fiber ?max_domains ?allow_lwt ?avoid_threads ?fatal_exn_handler fiber main;
119+ run_fiber ?verbose ?max_domains ?allow_lwt ?avoid_threads ?fatal_exn_handler
120+ fiber main;
105121 Computation. await computation
0 commit comments