Thread::setCurrentThreadName on Mac

Thread::setCurrentThreadName is calling the pthread_setname_np API directly. There are multiple advantages to calling +[NSThread setName:] instead:
[list][]pthread_setname_np is not documented. Apple could break it in the future. Or reject apps from the Mac App Store just for linking a library that uses it. Neither one seems likely, but still, better safe than sorry.[/]
[]setName: exists in 10.5, and does some kind of secret magic that means Xcode 3.2 can actually see your thread names even though gdb can’t.[/]
[]pthread_setname_np has mysterious errors sometimes in 10.6, and different mysterious errors in sandboxed apps in 10.7. And, when it fails, sometimes it returns the errnum, other times it returns -1 and you have to check errno, and there’s no way to know which.[/]
[]Whatever secret magic setName: uses seems to mean Xcode 3.2 and 4.x can see the full thread name, even if the pthread_setname_np one gets truncated.[/][/list]

Fair point! Thanks, I’ll have another look at that!