summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-11-21 14:12:01 +0000
committerBenny Prijono <bennylp@teluu.com>2007-11-21 14:12:01 +0000
commit5931dc59c08af2cf1f23518f700e9107effa9e59 (patch)
tree82f144feae2c2eb35b1f65f9edc156365152e347 /pjlib
parent7cea28ab2a2d6dadb0ef3aaa6a3194e45f98cba5 (diff)
Ticket #417: added pjlib API to retrieve the native thread handle from pj_thread_t
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1589 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/include/pj/os.h13
-rw-r--r--pjlib/src/pj/os_core_symbian.cpp17
-rw-r--r--pjlib/src/pj/os_core_unix.c14
-rw-r--r--pjlib/src/pj/os_core_win32.c15
4 files changed, 59 insertions, 0 deletions
diff --git a/pjlib/include/pj/os.h b/pjlib/include/pj/os.h
index 3529c463..f640df21 100644
--- a/pjlib/include/pj/os.h
+++ b/pjlib/include/pj/os.h
@@ -138,6 +138,19 @@ PJ_DECL(pj_bool_t) pj_thread_is_registered(void);
/**
+ * Return native handle from pj_thread_t for manipulation using native
+ * OS APIs.
+ *
+ * @param thread PJLIB thread descriptor.
+ *
+ * @return Native thread handle. For example, when the
+ * backend thread uses pthread, this function will
+ * return pointer to pthread_t, and on Windows,
+ * this function will return HANDLE.
+ */
+PJ_DECL(void*) pj_thread_get_os_handle(pj_thread_t *thread);
+
+/**
* Get thread name.
*
* @param thread The thread handle.
diff --git a/pjlib/src/pj/os_core_symbian.cpp b/pjlib/src/pj/os_core_symbian.cpp
index 8f96ce09..f656cb68 100644
--- a/pjlib/src/pj/os_core_symbian.cpp
+++ b/pjlib/src/pj/os_core_symbian.cpp
@@ -447,6 +447,23 @@ PJ_DEF(pj_bool_t) pj_symbianos_poll(int priority, int ms_timeout)
/*
+ * pj_thread_is_registered()
+ */
+PJ_DEF(pj_bool_t) pj_thread_is_registered(void)
+{
+ return PJ_FALSE;
+}
+
+/*
+ * pj_thread_get_os_handle()
+ */
+PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread)
+{
+ PJ_UNUSED_ARG(thread);
+ return NULL;
+}
+
+/*
* pj_thread_register(..)
*/
PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name,
diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c
index e901036a..5a246df5 100644
--- a/pjlib/src/pj/os_core_unix.c
+++ b/pjlib/src/pj/os_core_unix.c
@@ -238,6 +238,20 @@ PJ_DEF(pj_bool_t) pj_thread_is_registered(void)
#endif
}
+/*
+ * Get native thread handle
+ */
+PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread)
+{
+ PJ_ASSERT_RETURN(thread, NULL);
+
+#if PJ_HAS_THREADS
+ return &thread->thread;
+#else
+ pj_assert("pj_thread_is_registered() called in non-threading mode!");
+ return NULL;
+#endif
+}
/*
* pj_thread_register(..)
diff --git a/pjlib/src/pj/os_core_win32.c b/pjlib/src/pj/os_core_win32.c
index b9484ff5..fcacaf4b 100644
--- a/pjlib/src/pj/os_core_win32.c
+++ b/pjlib/src/pj/os_core_win32.c
@@ -245,6 +245,21 @@ PJ_DEF(pj_bool_t) pj_thread_is_registered(void)
}
/*
+ * Get native thread handle
+ */
+PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread)
+{
+ PJ_ASSERT_RETURN(thread, NULL);
+
+#if PJ_HAS_THREADS
+ return thread->hthread;
+#else
+ pj_assert("pj_thread_is_registered() called in non-threading mode!");
+ return NULL;
+#endif
+}
+
+/*
* pj_thread_register(..)
*/
PJ_DEF(pj_status_t) pj_thread_register ( const char *cstr_thread_name,