task: Add thread name support on OS X and iOS

This commit is contained in:
Ilya Konstantinov 2015-02-01 03:39:03 +02:00 committed by Sebastian Dröge
parent c3963ae7a3
commit 05296b35a5
2 changed files with 29 additions and 2 deletions

View file

@ -346,6 +346,18 @@ AM_CONDITIONAL(HAVE_PTHREAD, test "x$ax_pthread_ok" = "xyes")
dnl check for sys/prctl for setting thread name on Linux
AC_CHECK_HEADERS([sys/prctl.h], [], [], [AC_INCLUDES_DEFAULT])
dnl check for pthread_setname_np(const char*)
dnl which is present on OS X 10.6, iOS 3.2 and above
AC_MSG_CHECKING(for pthread_setname_np(const char*))
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include <pthread.h>],
[pthread_setname_np("example")])],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
[Have function pthread_setname_np(const char*)])],
[AC_MSG_RESULT(no)])
dnl check for sys/uio.h for writev()
AC_CHECK_HEADERS([sys/uio.h], [], [], [AC_INCLUDES_DEFAULT])

View file

@ -78,6 +78,10 @@
#include <sys/prctl.h>
#endif
#ifdef HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID
#include <pthread.h>
#endif
GST_DEBUG_CATEGORY_STATIC (task_debug);
#define GST_CAT_DEFAULT (task_debug)
@ -246,8 +250,19 @@ gst_task_configure_name (GstTask * task)
GST_DEBUG_OBJECT (task, "Failed to set thread name");
}
GST_OBJECT_UNLOCK (task);
#endif
#ifdef _MSC_VER
#elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
const gchar *name;
GST_OBJECT_LOCK (task);
name = GST_OBJECT_NAME (task);
/* set the thread name to something easily identifiable */
GST_DEBUG_OBJECT (task, "Setting thread name to '%s'", name);
if (pthread_setname_np (name))
GST_DEBUG_OBJECT (task, "Failed to set thread name");
GST_OBJECT_UNLOCK (task);
#elif _MSC_VER
const gchar *name;
name = GST_OBJECT_NAME (task);