cqueues
cqueues copied to clipboard
add thread:setname and thread:getname
Adds wrappers for pthread_setname_np and pthread_getname_np to the thread metatable. It's quite useful to be able to name long-running threads!
Is pthread_setname_np available on all cqueues supported platforms? (an _np suffix usually means "non-posix", which means that the function is not well supported)
Some quick googling suggests:
- The API was only introduced in glibc 2.12, you may need to add a preprocessor check?
- On FreeBSD you may need to
#include <pthread_np.h>? - NetBSD+OpenBSD might have a different number of arguments to linux?
- OSX has a different form again? Only lets you set for the current thread? This may necessitate that you copy the name away and then set it as part of thread initialisation.
Oh, you're right, that's quite a mess. I've added checks to explicitly support the relevant functions on Linux, the BSDs and OS X.