Skip to content

Commit

Permalink
Add Eio_unix.Fd.is_open convenience function
Browse files Browse the repository at this point in the history
  • Loading branch information
talex5 committed Feb 13, 2024
1 parent b50071d commit 81b9048
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib_eio/unix/fd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ let is_seekable t =
t.seekable <- if seekable then Yes else No;
seekable

let is_open t = Rcfd.is_open t.fd

let rec use_exn_list op xs k =
match xs with
| [] -> k []
Expand Down
6 changes: 6 additions & 0 deletions lib_eio/unix/fd.mli
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ val remove : t -> Unix.file_descr option
Returns [None] if [t] is closed by another fiber first. *)

val is_open : t -> bool
(** [is_open t] returns [true] until [t] has been marked as closing, after which it returns [false].
This is mostly useful inside the callback of {!use}, to test whether
another fiber has started closing [t] (in which case you may decide to stop early). *)

(** {2 Flags} *)

val is_blocking : t -> bool
Expand Down

0 comments on commit 81b9048

Please sign in to comment.