Add .set_blocking to Socket and IO::FileDescriptor and deprecate the blocking args#15924
Conversation
|
Back to draft. Waiting for #15930. |
3c44c1d to
cc31269
Compare
Explicits that the fd/handle will be configured to match the event loop requirements when adopted in the Socket types (its configuration will be changed). Explicits that `#fd` returns the fd/handle configured for the current event loop, and no specific configuration must be expected. Explicits that changing a socket's blocking mode can break the event loop, and as such must be treated carefully.
Explicits that the fd/handle will be configured to match the event loop requirements when adopted in the Socket types (its configuration will be changed). Explicits that `#fd` returns the fd/handle configured for the current event loop, and no specific configuration must be expected. Explicits that changing a socket's blocking mode can break the event loop, and as such must be treated carefully.
cc31269 to
27db4c0
Compare
|
Rebased from master to remove conflicts with #15930. |
|
I realize I only added EDIT: I didn't write it because we can't change the mode on Windows. It might be useful on UNIX, though. |
|
I added I added specs for it and |
…soft-deprecate-blocking-args
Extracted documentation-only changes from #15924 Co-authored-by: Julien Portalier <julien@portalier.com>
|
I extracted the doc enhancements to #15977 for 1.17. |
…et-and-file-fd-ownership+soft-deprecate-blocking-args
.set_blocking to Socket and IO::FileDescriptor and deprecate the blocking args
|
I fixed the conflicts with Since we can annotate a method argument, and there's no rush to merge this PR, I'll try to see if I can get compiler warnings for a deprecated method argument (we can annotate them), and update this PR accordingly. We'll need docs to reflect this, too, but compilation warnings would be a good start. |
…et-and-file-fd-ownership+soft-deprecate-blocking-args-take-2
|
Merged with |
|
Actually, we should separate the addition of Sorry for being that guy again. But I'm sure it's for the best 🙇 |
|
Argh, The Crystal 1.0 parser doesn't support annotations on method args. It was only added in #12044 for Crystal 1.5. |
Improves the documentation around the system file descriptors and handles inIO::FileDescriptorandSocketin relation to "adopting" the fd/handle into the IO system, or accessing it. I hope it starts to clarify the intent.The documentation
also softdeprecates theblockingargument of their constructors.Sadly, except for a few cases, I can't use theNow uses the@[Deprecated]annotation and the usual two methods trick (one without the arg, and a deprecated one with the arg) because the blocking arg is positional and comes after default arguments.@[Deprecated]annotation on methods args that depends on #15999.Also deprecates the
#blocking?and#blocking=methods that would mess with anIO::FileDescriptororSocketblocking mode that has been configured by the event loop, that are replaced by class methods:Socket.set_blocking(Bool)(UNIX and Windows targets);IO::FileDescriptor.set_blocking(Bool)(UNIX targets only).My doc-fu ain't the best. If you're more capable and find better phrasing, feel free to edit the PR 🙇Follow up to #15804, #15754, #15753, #15750, #15930, #15977.