From 7e41f9d1081ff0c5c335da4ae21f0d76c7d8edc9 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Fri, 27 Jul 2018 16:53:26 +0300 Subject: 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. --- src/nxt_thread.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/nxt_thread.c') 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 +} -- cgit