-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement Lock.swift on Windows #2080
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
Conversation
Sources/Basic/Lock.swift
Outdated
@@ -53,6 +57,30 @@ public final class FileLock { | |||
/// | |||
/// Note: This method can throw if underlying POSIX methods fail. | |||
public func lock() throws { | |||
#if os(Windows) |
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.
Minor note on indenting:
#if
statements should be indented two-space less than the regular code. See example: https://github.com/apple/swift-package-manager/blob/master/Sources/PackageDescription4/Package.swift#L68- SwiftPM uses 4-space indent for regular code.
- When breaking a method into multiple lines, indent the parameters to the left of the call: Ex: https://github.com/apple/swift-package-manager/blob/master/Sources/Workspace/Workspace.swift#L370
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! Looks great, just left some minor notes on indenting.
Fixed up the indenting |
@swift-ci smoke test |
@swift-ci smoke test linux |
@@ -36,7 +36,11 @@ enum ProcessLockError: Swift.Error { | |||
/// by mutiple instances of a process. The `FileLock` is not thread-safe. | |||
public final class FileLock { | |||
/// File descriptor to the lock file. | |||
#if os(Windows) | |||
private var h: 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.
Why not at least handle
instead of h
for this variable?
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.
Renaming to handle
would be nice to have. Feel free to make a PR :)
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.
@aciidb0mb3r PR #2093 ;)
@@ -36,7 +36,11 @@ enum ProcessLockError: Swift.Error { | |||
/// by mutiple instances of a process. The `FileLock` is not thread-safe. | |||
public final class FileLock { | |||
/// File descriptor to the lock file. | |||
#if os(Windows) | |||
private var h: HANDLE? | |||
#else | |||
private var fd: CInt? |
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.
What fd
stands for?
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.
file descriptor
No description provided.