Created
November 10, 2016 10:16
-
-
Save ucotta/dab6fa3f5cc86d4d48ae461069d662f2 to your computer and use it in GitHub Desktop.
Swift: NSTask with 0% cpu
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
// This task will run for ever a task get 0% of cpu | |
// dont use waitUntil because it will consume you cpu | |
import Foundation | |
extension Task { | |
public func waitUntilWithSleep() { | |
while running { | |
// sleep for 0.1 seconds | |
usleep(10000) | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I created this method to run a Perfect.org server for ever...