Skip to content
Permalink
Browse files

swift 4 changes

  • Loading branch information...
Michael Gray
Michael Gray committed Jun 13, 2017
1 parent c76447e commit 41885463439084eb87577362da3566b057ec1d78
@@ -755,6 +755,7 @@
0DDE325F1B38BD27007C39D9 = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = AUXUTTBC4T;
LastSwiftMigration = 0900;
};
0DDE32731B38BD28007C39D9 = {
CreatedOnToolsVersion = 6.3.2;
@@ -764,7 +765,7 @@
0DEA1B901AE30853000E126F = {
CreatedOnToolsVersion = 6.3;
DevelopmentTeam = AUXUTTBC4T;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
0DEA1BAE1AE30872000E126F = {
@@ -774,7 +775,7 @@
0DEA1BE91AE3116A000E126F = {
CreatedOnToolsVersion = 6.3;
DevelopmentTeam = AUXUTTBC4T;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
TestTargetID = 0DDE325F1B38BD27007C39D9;
};
0DEA1BFE1AE313DD000E126F = {
@@ -1351,7 +1352,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.futureKit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -1370,7 +1372,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.futureKit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -1444,7 +1447,8 @@
PRODUCT_NAME = FutureKit;
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -1469,7 +1473,8 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_DISABLE_SAFETY_CHECKS = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -1540,7 +1545,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.futurekit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "FutureKitTests/FutureKit iOS Tests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FutureKit iOS Testing App.app/FutureKit iOS Testing App";
};
name = Debug;
@@ -1559,7 +1565,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.futurekit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "FutureKitTests/FutureKit iOS Tests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FutureKit iOS Testing App.app/FutureKit iOS Testing App";
};
name = Release;
@@ -100,21 +100,21 @@ final public class Box<T> {
} */

private func make_dispatch_block<T>(_ q: DispatchQueue, _ block: @escaping (T) -> Void) -> ((T) -> Void) {
private func make_dispatch_block(_ q: DispatchQueue, _ block: @escaping () -> Void) -> (() -> Void) {

let newblock = { (t:T) -> Void in
let newblock = { () -> Void in
q.async {
block(t)
block()
}
}
return newblock
}

private func make_dispatch_block<T>(_ q: OperationQueue, _ block: @escaping (T) -> Void) -> ((T) -> Void) {
private func make_dispatch_block(_ q: OperationQueue, _ block: @escaping () -> Void) -> (() -> Void) {

let newblock = { (t:T) -> Void in
let newblock = { () -> Void in
q.addOperation({ () -> Void in
block(t)
block()
})
}
return newblock
@@ -135,8 +135,8 @@ public enum SerialOrConcurrent: Int {

}

internal extension Date {
internal static var now: Date {
public extension Date {
public static var now: Date {
return Date()
}
}
@@ -377,7 +377,7 @@ public enum Executor {
// // insert code to run in the QOS_CLASS_BACKGROUND queue!
// }
//
public func executeBlock(block b: @escaping ()->()) {
public func executeBlock(block b: @escaping (())->()) {
let executionBlock = self.callbackBlockFor(b)
executionBlock()
}
@@ -654,22 +654,32 @@ public enum Executor {
}

public func callbackBlockFor<T>(_ block: @escaping (T) -> Void) -> ((T) -> Void) {


return { (t:T) -> Void in
self.callbackBlockFor { () -> Void in
block(t)
}()
}
}

public func callbackBlockFor(_ block: @escaping () -> Void) -> (() -> Void) {

let currentExecutor = self.real_executor

switch currentExecutor {
case .immediate,.stackCheckingImmediate:
return currentExecutor.getblock_for_callbackBlockFor(block)
default:
let wrappedBlock = { (t:T) -> Void in
let wrappedBlock = { () -> Void in
let previous = Executor.setCurrentExecutor(currentExecutor)
block(t)
block()
Executor.setCurrentExecutor(previous)
}
return currentExecutor.getblock_for_callbackBlockFor(wrappedBlock)
}
}



/*
we need to figure out what the real executor we need to guarantee that execution will happen asyncronously.
@@ -729,7 +739,7 @@ public enum Executor {
}
}

fileprivate func getblock_for_callbackBlockFor<T>(_ block: @escaping (T) -> Void) -> ((T) -> Void) {
fileprivate func getblock_for_callbackBlockFor(_ block: @escaping () -> Void) -> (() -> Void) {

switch self {
case .primary:
@@ -746,13 +756,13 @@ public enum Executor {
return Executor.SmartCurrent.asyncExecutor.getblock_for_callbackBlockFor(block)

case .mainImmediate:
let newblock = { (t:T) -> Void in
let newblock = { () -> Void in
if (Thread.isMainThread) {
block(t)
block()
}
else {
Executor.mainQ.async {
block(t)
block()
}
}
}
@@ -782,9 +792,9 @@ public enum Executor {
return Executor.MainExecutor.getblock_for_callbackBlockFor(block)
}
else {
let newblock = { (t:T) -> Void in
let newblock = { () -> Void in
context.perform {
block(t)
block()
}
}
return newblock
@@ -794,27 +804,27 @@ public enum Executor {
case .immediate:
return block
case .stackCheckingImmediate:
let b = { (t:T) -> Void in
let b = { () -> Void in
let threadDict = Thread.current.threadDictionary
let currentDepth = (threadDict[GLOBAL_PARMS.STACK_CHECKING_PROPERTY] as? Int32) ?? 0;
if (currentDepth > GLOBAL_PARMS.STACK_CHECKING_MAX_DEPTH) {
let b = Executor.AsyncExecutor.callbackBlockFor(block)
b(t)
b()
}
else {
let newDepth = currentDepth + 1;
threadDict[GLOBAL_PARMS.STACK_CHECKING_PROPERTY] = newDepth
block(t)
block()
threadDict[GLOBAL_PARMS.STACK_CHECKING_PROPERTY] = currentDepth
}
}
return b

case let .custom(customCallBack):

let b = { (t:T) -> Void in
let b = { () -> Void in
customCallBack { () -> Void in
block(t)
block()
}
}

@@ -769,7 +769,7 @@ open class Future<T> : FutureProtocol {
internal final func completeWithBlocks<C:CompletionType>(
waitUntilDone wait:Bool = false,
completionBlock : @escaping () throws -> C,
onCompletionError : @escaping () -> Void = { _ in return } ) where C.T == T {
onCompletionError : @escaping () -> Void = {} ) where C.T == T {

typealias ModifyBlockReturnType = (callbacks:[completion_block_type]?,
result:FutureResult<T>?,
@@ -175,7 +175,9 @@ open class FutureBatchOf<T> {
}

// As soon as the first Future fails, call the block handler.
failOrCancelPromise.future.onSuccess(executor) { (result,future,index) in
failOrCancelPromise.future.onSuccess(executor) { (arg) -> Void in

let (result, future, index) = arg
block(result, future, index)
}.ignoreFailures()
}
@@ -182,7 +182,7 @@ private enum PromiseState<T : Equatable> : CustomStringConvertible, CustomDebug
future.onSuccess (futureExecutor) { (value) -> Void in
XCTFail("Did not expect onSuccess \(value)")
}.ignoreFailures()
future.onCancel (futureExecutor) { (_) -> Void in
future.onCancel (futureExecutor) { () -> Void in
onCancelExpectation.fulfill()
}
future.onFail (futureExecutor) { (error) -> Void in

0 comments on commit 4188546

Please sign in to comment.
You can’t perform that action at this time.