Skip to content

Instantly share code, notes, and snippets.

@blinker13
Created August 7, 2015 13:57
Show Gist options
  • Save blinker13/304d98ac77c5ee9aac51 to your computer and use it in GitHub Desktop.
Save blinker13/304d98ac77c5ee9aac51 to your computer and use it in GitHub Desktop.
Calling pthread_getname_np() in Swift
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