Skip to content

Commit a2dd56b

Browse files
committed
add additional guards for building NSOperation on linux without DEPLOYMENT_ENABLE_LIBDISPATCH
1 parent bc3abbf commit a2dd56b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Foundation/NSOperation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,12 @@ public class NSOperationQueue : NSObject {
374374
}
375375

376376
public func addOperations(ops: [NSOperation], waitUntilFinished wait: Bool) {
377+
#if DEPLOYMENT_ENABLE_LIBDISPATCH
377378
var waitGroup: dispatch_group_t?
378379
if wait {
379380
waitGroup = dispatch_group_create()
380381
}
382+
#endif
381383
/*
382384
If OperationQueuePriority was not supported this could be much faster
383385
since it would not need to have the extra book-keeping for managing a priority
@@ -527,6 +529,7 @@ public class NSOperationQueue : NSObject {
527529
static let OperationQueueKey = UnsafePointer<Void>(UnsafeMutablePointer<Void>(allocatingCapacity: 1))
528530

529531
public class func currentQueue() -> NSOperationQueue? {
532+
#if DEPLOYMENT_ENABLE_LIBDISPATCH
530533
let specific = dispatch_get_specific(NSOperationQueue.OperationQueueKey)
531534
if specific == nil {
532535
if pthread_main_np() == 1 {
@@ -537,6 +540,9 @@ public class NSOperationQueue : NSObject {
537540
} else {
538541
return Unmanaged<NSOperationQueue>.fromOpaque(unsafeBitCast(specific, to: OpaquePointer.self)).takeUnretainedValue()
539542
}
543+
#else
544+
return nil
545+
#endif
540546
}
541547

542548
public class func mainQueue() -> NSOperationQueue {

0 commit comments

Comments
 (0)