Skip to content

Commit

Permalink
Merge pull request #702 from talex5/execpool-err
Browse files Browse the repository at this point in the history
Executor_pool: mention requested weight in error message
  • Loading branch information
talex5 authored Feb 23, 2024
2 parents 4f3ec08 + e5444c0 commit 57c0207
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib_eio/executor_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let create ~sw ~domain_count domain_mgr =

let enqueue { queue } ~weight fn =
if not (weight >= 0. && weight <= 1.) (* Handles NaN *)
then Fmt.invalid_arg "Executor_pool: weight not >= 0.0 && <= 1.0" weight
then Fmt.invalid_arg "Executor_pool: weight %g not >= 0.0 && <= 1.0" weight
else (
let weight = Float.to_int (weight *. max_capacity_f) in
let p, w = Promise.create () in
Expand Down
4 changes: 2 additions & 2 deletions tests/executor_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ Must be between 0 and 1:
let pool = Executor_pool.create ~sw ~domain_count:2 mgr in
Executor_pool.submit_exn pool ~weight:(-5.) (fun () -> ())
;;
Exception: Invalid_argument "Executor_pool: weight not >= 0.0 && <= 1.0".
Exception: Invalid_argument "Executor_pool: weight -5 not >= 0.0 && <= 1.0".
```
```ocaml
# run @@ fun mgr sleep duration ->
Switch.run @@ fun sw ->
let pool = Executor_pool.create ~sw ~domain_count:2 mgr in
Executor_pool.submit_exn pool ~weight:1.1 (fun () -> ())
;;
Exception: Invalid_argument "Executor_pool: weight not >= 0.0 && <= 1.0".
Exception: Invalid_argument "Executor_pool: weight 1.1 not >= 0.0 && <= 1.0".
```


Expand Down

0 comments on commit 57c0207

Please sign in to comment.