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.
This commit is contained in:
Igor Sysoev
2018-07-27 16:53:26 +03:00
parent de885e10cb
commit 7e41f9d108
4 changed files with 150 additions and 175 deletions

View File

@@ -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
}