Source file threads.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
open Core

type t = int [@@deriving sexp_of]

let create threads =
  if threads <= 0
  then raise_s [%message "number of threads must be one or more" (threads : int)];
  threads
;;

let to_int t = t
let to_string = Int.to_string

let flag name =
  [%map_open.Command
    let threads =
      flag name (optional_with_default 1 int) ~doc:"Number of parallel threads (>0)"
    in
    create threads]
;;