@@ -19,7 +19,14 @@ open class FileHandle : NSObject, NSSecureCoding {
19
19
internal var _fd : Int32
20
20
internal var _closeOnDealloc : Bool
21
21
internal var _closed : Bool = false
22
-
22
+
23
+ open var readabilityHandler : ( ( FileHandle ) -> Void ) ? = {
24
+ ( FileHandle) -> Void in NSUnimplemented ( )
25
+ }
26
+ open var writeabilityHandler : ( ( FileHandle ) -> Void ) ? = {
27
+ ( FileHandle) -> Void in NSUnimplemented ( )
28
+ }
29
+
23
30
open var availableData : Data {
24
31
return _readDataOfLength ( Int . max, untilEOF: false )
25
32
}
@@ -346,14 +353,6 @@ extension FileHandle {
346
353
open func waitForDataInBackgroundAndNotify( ) {
347
354
NSUnimplemented ( )
348
355
}
349
-
350
- open var readabilityHandler : ( ( FileHandle ) -> Void ) ? {
351
- NSUnimplemented ( )
352
- }
353
-
354
- open var writeabilityHandler : ( ( FileHandle ) -> Void ) ? {
355
- NSUnimplemented ( )
356
- }
357
356
}
358
357
359
358
extension FileHandle {
@@ -367,9 +366,9 @@ extension FileHandle {
367
366
}
368
367
369
368
open class Pipe : NSObject {
370
- private let readHandle : FileHandle
371
- private let writeHandle : FileHandle
372
-
369
+ open let fileHandleForReading : FileHandle
370
+ open let fileHandleForWriting : FileHandle
371
+
373
372
public override init ( ) {
374
373
/// the `pipe` system call creates two `fd` in a malloc'ed area
375
374
var fds = UnsafeMutablePointer< Int32> . allocate( capacity: 2 )
@@ -383,19 +382,11 @@ open class Pipe: NSObject {
383
382
/// don't need to add a `deinit` to this class
384
383
385
384
/// Create the read handle from the first fd in `fds`
386
- self . readHandle = FileHandle ( fileDescriptor: fds. pointee, closeOnDealloc: true )
385
+ self . fileHandleForReading = FileHandle ( fileDescriptor: fds. pointee, closeOnDealloc: true )
387
386
388
387
/// Advance `fds` by one to create the write handle from the second fd
389
- self . writeHandle = FileHandle ( fileDescriptor: fds. successor ( ) . pointee, closeOnDealloc: true )
388
+ self . fileHandleForWriting = FileHandle ( fileDescriptor: fds. successor ( ) . pointee, closeOnDealloc: true )
390
389
391
390
super. init ( )
392
391
}
393
-
394
- open var fileHandleForReading : FileHandle {
395
- return self . readHandle
396
- }
397
-
398
- open var fileHandleForWriting : FileHandle {
399
- return self . writeHandle
400
- }
401
392
}
0 commit comments