Skip to content

Commit

Permalink
Merge pull request swiftlang#1955 from compnerd/incase-of-emergency-g…
Browse files Browse the repository at this point in the history
…lue-the-window

HACK: make FileHandle build on Windows again
  • Loading branch information
millenomi authored Mar 12, 2019
2 parents 0a6f09b + fc0f8d6 commit a132f6e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Foundation/FileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,6 @@ open class FileHandle : NSObject, NSSecureCoding {
return source
}

#if os(Windows)
@available(*, unavailable, message: "Not yet implemented on Windows")
open var readabilityHandler: ((FileHandle) -> Void)? = {
(FileHandle) -> Void in NSUnimplemented()
}

@available(*, unavailable, message: "Not yet implemented on Windows")
open var writeabilityHandler: ((FileHandle) -> Void)? = {
(FileHandle) -> Void in NSUnimplemented()
}
#else
private var _readabilityHandler: ((FileHandle) -> Void)? = nil // Guarded by privateAsyncVariablesLock
open var readabilityHandler: ((FileHandle) -> Void)? {
get {
Expand Down Expand Up @@ -200,7 +189,6 @@ open class FileHandle : NSObject, NSSecureCoding {
}
}
}
#endif

open var availableData: Data {
_checkFileHandle()
Expand Down Expand Up @@ -891,7 +879,11 @@ extension FileHandle {
acceptConnectionInBackgroundAndNotify(forModes: [.default])
}

@available(Windows, unavailable, message: "A SOCKET cannot be treated as a fd")
open func acceptConnectionInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?) {
#if os(Windows)
NSUnavailable()
#else
let owner = monitor(forReading: true, resumed: false) { (handle, source) in
var notification = Notification(name: .NSFileHandleConnectionAccepted, object: handle, userInfo: [:])
let userInfo: [AnyHashable : Any]
Expand Down Expand Up @@ -919,6 +911,7 @@ extension FileHandle {
privateAsyncVariablesLock.unlock()

owner.resume()
#endif
}

open func waitForDataInBackgroundAndNotify() {
Expand Down

0 comments on commit a132f6e

Please sign in to comment.