diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-01-23 12:17:22 -0800 |
---|---|---|
committer | atrnati <54334261+atrnati@users.noreply.github.com> | 2020-01-29 08:47:50 -0600 |
commit | 45c67acf8f0e342a24a20efe3bcb1f5a82c282f8 (patch) | |
tree | 66e4434ef99afe8b2b2fabeef4e7b7d6fc366c8f /host/lib | |
parent | 657cc4c06249aa9897e6d286fa5eadb1a3506b4b (diff) | |
download | uhd-45c67acf8f0e342a24a20efe3bcb1f5a82c282f8.tar.gz uhd-45c67acf8f0e342a24a20efe3bcb1f5a82c282f8.tar.bz2 uhd-45c67acf8f0e342a24a20efe3bcb1f5a82c282f8.zip |
thread: Remove log messages for set_thread_name() when not supported
On systems like Windows, set_thread_name() is not supported, and would
previously log an error message telling the user that it can't set the
thread name. However, that prevents set_thread_name() to be called
before the logger is being set up, and the logger would like to use this
function.
Since it is obvious to the user if threads can be named or not, the log
message is considered redundant and is removed.
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/utils/thread.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/host/lib/utils/thread.cpp b/host/lib/utils/thread.cpp index e5dde06b2..a2beb955b 100644 --- a/host/lib/utils/thread.cpp +++ b/host/lib/utils/thread.cpp @@ -167,21 +167,25 @@ static void check_priority_range(float priority){ void uhd::set_thread_name(boost::thread* thrd, const std::string& name) { #ifdef HAVE_PTHREAD_SETNAME - pthread_setname_np(thrd->native_handle(), name.substr(0,16).c_str()); + 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); + // Then we can't set the thread name. This function may get called + // before the logger starts, and thus can't log any error messages. + // Note that CMake will also tell the user about not being able to set + // thread names. #endif /* HAVE_THREAD_SETNAME_DUMMY */ -} + } -void uhd::set_thread_name( - std::thread *thrd, - const std::string &name -) { + 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()); + 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); + // Then we can't set the thread name. This function may get called + // before the logger starts, and thus can't log any error messages. + // Note that CMake will also tell the user about not being able to set + // thread names. #endif /* HAVE_THREAD_SETNAME_DUMMY */ -} + } |