-
Notifications
You must be signed in to change notification settings - Fork 721
Use Swift System to implement NonBlockingFileIO #2099
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
Use Swift System to implement NonBlockingFileIO #2099
Conversation
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
Signed-off-by: Si Beaumont <[email protected]>
|
@Lukasa any thoughts on this one? |
| } | ||
|
|
||
| extension NIOFileHandle { | ||
| public func withUnsafeSystemFileDescriptor<T>(_ body: (SystemPackage.FileDescriptor) throws -> T) throws -> T { |
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.
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.
It does have FileDescriptor on Windows but, now you mention it, we explicitly opted to not include resize() on Windows. See apple/swift-system#82.
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.
That is easily accomplished with SetFilePointerEx and SetEndOfFile; you will need _get_osfhandle to convert the file descriptor to the appropriate handle.
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.
Thanks @compnerd. I guess that means that this (NIO) PR is probably blocked on a follow-up PR to swift-system to make sure that Windows has a FileDescriptor.resize(to:) implementation.
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.
Here's the PR for a Windows implementation of FileDescriptor.resize(to:): apple/swift-system#89
1proprogrammerchant
left a comment
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.
seems the commits are out of date to the branch
Yeah, this one died on the vine. And the addition of |
|
We’ve deprecated NonBlockingFileIO. |
Motivation:
#1957 suggests we make use of Swift System for the
NonBlockingFileIOimplementation which would also reduce its dependency onNIOPosix.Modifications:
NonBlockingFileIOwith System'sFileDescriptor-based implementation.To do:
withUnsafeSystemFileDescriptorfunction (probably not initially?)