summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_thread.c
diff options
context:
space:
mode:
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
+}