Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executor_pool: mention requested weight in error message #702

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading