File tree Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 11(library
22 (name examples)
33 (modules
4- (:standard \ main))
5- (libraries progress unix logs logs.fmt logs.threaded fmt fmt.tty mtime
6- mtime.clock.os vector threads.posix))
4+ (:standard \ main ocaml5))
5+ (libraries
6+ progress
7+ unix
8+ logs
9+ logs.fmt
10+ logs.threaded
11+ fmt
12+ fmt.tty
13+ mtime
14+ mtime.clock.os
15+ vector
16+ threads.posix))
717
818(executable
919 (name main)
1020 (modules main)
1121 (libraries examples fmt))
22+
23+ (executable
24+ (name ocaml5)
25+ (modules ocaml5)
26+ (libraries progress domainslib))
Original file line number Diff line number Diff line change 1+ let domains_count = 2
2+
3+ let () =
4+ let xs = Array. init 100 (Fun. id) in
5+ let len = Array. length xs in
6+ let total = if len > 0 then len * (len - 1 ) / 2 else 0 in
7+ let bar ~total =
8+ let open Progress.Line in
9+ list
10+ [
11+ spinner () ;
12+ bar total;
13+ count_to total;
14+ ]
15+ in
16+ let useful_stuff _i _j = () in
17+ let module T = Domainslib. Task in
18+ let pool = T. setup_pool ~num_domains: domains_count () in
19+ Progress. with_reporter (bar ~total )
20+ (fun report ->
21+ T. run pool (fun () ->
22+ T. parallel_for pool ~start: 0 ~finish: (len - 1 ) ~body: (fun i ->
23+ T. parallel_for pool ~start: (i + 1 ) ~finish: (len - 1 )
24+ ~body: (fun j ->
25+ report 1 ;
26+ useful_stuff i j))));
27+ T. teardown_pool pool
You can’t perform that action at this time.
0 commit comments