Skip to content

Commit

Permalink
Eio.Pool.use: move never_block argument
Browse files Browse the repository at this point in the history
Optional arguments should go first so that it's obvious to the compiler
when they're not being used. Example of a program where this makes a
difference:

    let run use = use ignore

    let () =
      let p = Eio.Pool.create 1 ignore in
      run (Eio.Pool.use p)
  • Loading branch information
talex5 committed Aug 7, 2024
1 parent 33d4e01 commit 05539c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib_eio/pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let run_new_and_dispose t f =
t.dispose x;
Printexc.raise_with_backtrace ex bt

let use t ?(never_block=false) f =
let use ?(never_block=false) t f =
let segment, cell = Q.next_suspend t.q in
match Atomic.get cell with
| Finished | Request _ -> assert false
Expand Down
2 changes: 1 addition & 1 deletion lib_eio/pool.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ val create :
If it raises, the exception is passed on to the user,
but resource is still considered to have been disposed. *)

val use : 'a t -> ?never_block:bool -> ('a -> 'b) -> 'b
val use : ?never_block:bool -> 'a t -> ('a -> 'b) -> 'b
(** [use t fn] waits for some resource [x] to be available and then runs [f x].
Afterwards (on success or error), [x] is returned to the pool.
Expand Down

0 comments on commit 05539c8

Please sign in to comment.