summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_thread.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2018-07-27 16:53:26 +0300
committerIgor Sysoev <igor@sysoev.ru>2018-07-27 16:53:26 +0300
commit7e41f9d1081ff0c5c335da4ae21f0d76c7d8edc9 (patch)
tree48ced5cd8efe8bf61bf961c468a2e6fa5d88956e /src/nxt_thread.c
parentde885e10cb895751d9994e8ab99bdb56da891d3d (diff)
downloadunit-7e41f9d1081ff0c5c335da4ae21f0d76c7d8edc9.tar.gz
unit-7e41f9d1081ff0c5c335da4ae21f0d76c7d8edc9.tar.bz2
Refactored thread ID functions.
nxt_thread_tid() was moved to src/nxt_thread.c nxt_thread_get_tid() was moved to src/nxt_thread_id.h. src/nxt_thread_id.c was removed.
Diffstat (limited to 'src/nxt_thread.c')
-rw-r--r--src/nxt_thread.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/nxt_thread.c b/src/nxt_thread.c
index a4ef416f..72429f4d 100644
--- a/src/nxt_thread.c
+++ b/src/nxt_thread.c
@@ -237,3 +237,35 @@ nxt_thread_wait(nxt_thread_handle_t handle)
nxt_main_log_alert("pthread_join(%PH) failed %E", handle, err);
}
}
+
+
+nxt_tid_t
+nxt_thread_tid(nxt_thread_t *thr)
+{
+ if (thr == NULL) {
+ thr = nxt_thread();
+ }
+
+#if (NXT_HAVE_THREAD_STORAGE_CLASS)
+
+ if (nxt_slow_path(thr->tid == 0)) {
+ thr->tid = nxt_thread_get_tid();
+ }
+
+ return thr->tid;
+
+#else
+
+ if (nxt_fast_path(thr != NULL)) {
+
+ if (nxt_slow_path(thr->tid == 0)) {
+ thr->tid = nxt_thread_get_tid();
+ }
+
+ return thr->tid;
+ }
+
+ return nxt_thread_get_tid();
+
+#endif
+}