Description
Both Solaris 11 and recentish Illumos provide the same pthread_setname_np()
API.
While libstd can't presume the existence of the symbol, it seems like using weak!
works sufficiently to set the thread name when necessary.
While the implementation is different, the API is basically the same for the purposes of set_name()
.
The Linux implementation of set_name()
will silently truncate the thread name, while the NetBSD (and I think, FreeBSD) will return an error. Since the std::thread
implementation has no way to return an error right now, we need to choose between silent truncation or silent failure. Given the risk of mis-identification in truncation (it's likely that the unique part of the name is the end), it seems best to fail silently instead. On the plus side, this API has significantly more space than Linux's.