Created
October 17, 2017 09:37
-
-
Save reejosamuel/5502b7be9f7749fc8af44dab7072e646 to your computer and use it in GitHub Desktop.
Operation and Dispatch queue executions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let queue1 = DispatchQueue(label: "com.reejo.test", | |
qos: .userInitiated, | |
attributes: .concurrent, | |
autoreleaseFrequency: .inherit, | |
target: DispatchQueue.global()) | |
queue1.async { | |
print("welcome!") | |
} | |
let operationQueue = OperationQueue() | |
let blockOperation = BlockOperation { | |
print("Welcome on BlockOperation") | |
} | |
blockOperation.queuePriority = .low | |
blockOperation.qualityOfService = .background | |
let dependentOperation = BlockOperation { | |
print("Pre block operation") | |
} | |
dependentOperation.queuePriority = .veryLow | |
dependentOperation.qualityOfService = .background | |
let plainOperation = Operation() | |
plainOperation.completionBlock = { | |
print("plain operation depending on none") | |
} | |
plainOperation.queuePriority = .veryHigh | |
blockOperation.addDependency(dependentOperation) | |
operationQueue.addOperation(blockOperation) | |
operationQueue.addOperation(dependentOperation) | |
operationQueue.addOperation(plainOperation) | |
// welcome! | |
// Pre block operation | |
// plain operation depending on none | |
// Welcome on BlockOperation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment