Created
August 7, 2015 13:57
-
-
Save blinker13/304d98ac77c5ee9aac51 to your computer and use it in GitHub Desktop.
Calling pthread_getname_np() in Swift
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
var chars:[Int8] = Array(count:128, repeatedValue:0) | |
let error = pthread_getname_np(pthread, &chars, chars.count) | |
assert(error == 0, "Could not retrieve thread name") | |
let characters = chars.filter { $0 != 0 }.map { UInt8($0) }.map(UnicodeScalar.init).map(Character.init) | |
let name = String(characters) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment