-
Notifications
You must be signed in to change notification settings - Fork 0
input with timeout #3
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
base: main
Are you sure you want to change the base?
Changes from all commits
d1c3842
21c308f
21eb389
79d9bbe
760e503
3773e46
54f4ed5
d938aa9
0e21e65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,18 @@ class type t_seekable = | |
| inherit Seekable.t | ||
| end | ||
|
|
||
| (** Input stream where [input] takes a timeout. | ||
| This is useful for network operations. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And for so many other operations!
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbh I don't know a lot of IOs that are truly non blocking besides networking? At least on linux, which is what I know, normal IOs on the filesystem are always blocking, for example. |
||
| @since NEXT_RELEASE *) | ||
| class type t_with_timeout = | ||
| object | ||
| inherit t | ||
|
|
||
| method input_with_timeout : float -> bytes -> int -> int -> int | ||
| (** [input_with_timeout t buf i len] tries to read [len] bytes into [buf] | ||
| at offset [i]. It raises {!Timeout.Timeout} after [t] seconds without a read *) | ||
| end | ||
|
|
||
| val create : | ||
| ?close:(unit -> unit) -> input:(bytes -> int -> int -> int) -> unit -> t | ||
c-cube marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
@@ -110,3 +122,11 @@ val copy_into : ?buf:bytes -> #t -> #Out.t -> unit | |
|
|
||
| val map_char : (char -> char) -> #t -> t | ||
| (** Transform the stream byte by byte *) | ||
|
|
||
| val input_with_timeout : #t_with_timeout -> float -> bytes -> int -> int -> int | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docstrings here mention "read" more often than "input", maybe these functions should also be named |
||
| (** [input_with_timeout t buf i len] tries to read [len] bytes into [buf] | ||
| at offset [i]. It raises {!Timeout.Timeout} after [t] seconds without a read. | ||
| @raise Invalid_argument if the arguments do not denote a valid slice. | ||
| @raise Timeout.Timeout if a read didn't succeed in [t] seconds. | ||
| @since NEXT_RELEASE | ||
| *) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unusual name, I would have gone with "codec" instead of "transducer" I think. Or maybe just "compressor".