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

Implement flock_* for Win32 #12766

Merged

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Nov 19, 2022

The implementation is analog to #12728 just for the Win32 API.

Closes #12681

@straight-shoota straight-shoota added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels Nov 19, 2022
@HertzDevil
Copy link
Contributor

Does this obsolete #12681?

@straight-shoota
Copy link
Member Author

Yes, this is a superior fiber-aware implementation. But I see there are some parts in that which we should keep.

Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

Looks great, thanks 🚀

Comment on lines +48 to +49
LOCKFILE_FAIL_IMMEDIATELY = DWORD.new(0x00000001)
LOCKFILE_EXCLUSIVE_LOCK = DWORD.new(0x00000002)
Copy link
Member

Choose a reason for hiding this comment

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

This is not really needed, right?

Suggested change
LOCKFILE_FAIL_IMMEDIATELY = DWORD.new(0x00000001)
LOCKFILE_EXCLUSIVE_LOCK = DWORD.new(0x00000002)
LOCKFILE_FAIL_IMMEDIATELY = 0x00000001
LOCKFILE_EXCLUSIVE_LOCK = 0x00000002

Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessarily, but that's only because DWORD is equivalent to the default integer type Int32.
Prior evidence:

FILE_TYPE_CHAR = DWORD.new(0x2)
FILE_TYPE_DISK = DWORD.new(0x1)
FILE_TYPE_PIPE = DWORD.new(0x3)
FILE_TYPE_UNKNOWN = DWORD.new(0x0)

@straight-shoota straight-shoota added this to the 1.7.0 milestone Nov 25, 2022
@straight-shoota straight-shoota merged commit c18b00e into crystal-lang:master Nov 28, 2022
@straight-shoota straight-shoota deleted the feature/win32-flock branch November 28, 2022 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants