diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2019-05-21 14:06:14 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:08 -0800 |
commit | 64dd48776c57750b7df556c3ce6058219bec111c (patch) | |
tree | f0237af95c22d60e29e40d9561587f62c6e957dc /host/lib/utils/thread.cpp | |
parent | 96a19dc03fe465f101853e1de9369780445f1724 (diff) | |
download | uhd-64dd48776c57750b7df556c3ce6058219bec111c.tar.gz uhd-64dd48776c57750b7df556c3ce6058219bec111c.tar.bz2 uhd-64dd48776c57750b7df556c3ce6058219bec111c.zip |
utils: Added set_thread_name for std::thread
Diffstat (limited to 'host/lib/utils/thread.cpp')
-rw-r--r-- | host/lib/utils/thread.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/host/lib/utils/thread.cpp b/host/lib/utils/thread.cpp index 893496243..d8f52c4c8 100644 --- a/host/lib/utils/thread.cpp +++ b/host/lib/utils/thread.cpp @@ -110,3 +110,15 @@ void uhd::set_thread_name( UHD_LOG_DEBUG("UHD", "Setting thread name is not implemented; wanted to set to " << name); #endif /* HAVE_THREAD_SETNAME_DUMMY */ } + +void uhd::set_thread_name( + std::thread *thrd, + const std::string &name +) { +#ifdef HAVE_PTHREAD_SETNAME + pthread_setname_np(thrd->native_handle(), name.substr(0,16).c_str()); +#endif /* HAVE_PTHREAD_SETNAME */ +#ifdef HAVE_THREAD_SETNAME_DUMMY + UHD_LOG_DEBUG("UHD", "Setting thread name is not implemented; wanted to set to " << name); +#endif /* HAVE_THREAD_SETNAME_DUMMY */ +} |