Skip to content
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

Add IO::FileDescriptor::Handle #14390

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Mar 22, 2024

Adds a generic type representing a platform-specific file descriptor handle, analog to Socket::Handle.

Resolves part of #14389

@volatile_fd : Atomic(Handle)

# Returns the raw file-descriptor handle. Its type is platform-specific.
def fd : Handle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Handle becomes LibC::HANDLE, wouldn't this type restriction need to be reverted back to Int?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if we want to go that way, we might need to split between the internal and external representation of the handle. Let's take this step by step, though. FileDescriptor:Handle is supposed to be a generic name used for public APIs.

The exact type is platform-specific, but it should be a concrete type, not Int.
We could consider using the same type on all platforms in the future (SizeT probably). But I fear that would be too much of a breaking change for Unix systems right now.

@straight-shoota straight-shoota added this to the 1.12.0 milestone Mar 24, 2024
@straight-shoota straight-shoota merged commit 5a8574b into crystal-lang:master Mar 25, 2024
57 of 58 checks passed
@straight-shoota straight-shoota deleted the feature/file_descriptor-handle branch March 25, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants