Created
April 14, 2017 02:00
-
-
Save egcode/ff0c78d0effa2b27342aaeb2c21ab4c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import Foundation | |
| public class GCD { | |
| public class func mainThread(block:@escaping () -> Void) { | |
| DispatchQueue.main.async {block()} | |
| } | |
| public class func mainThreadDelayed(delay: TimeInterval, block:@escaping () -> Void) { | |
| DispatchQueue.main.asyncAfter(deadline: .now() + delay) {block()} | |
| } | |
| public class func backgroundThread(block:@escaping () -> Void) { | |
| DispatchQueue.global(qos: .background).async {block()} | |
| } | |
| public class func backgroundThreadDelayed(delay: TimeInterval, block:@escaping () -> Void) { | |
| DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + delay) {block()} | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment