aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/thread.i
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/thread.i
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/thread.i')
-rw-r--r--util/system/thread.i82
1 files changed, 41 insertions, 41 deletions
diff --git a/util/system/thread.i b/util/system/thread.i
index 8cba505473..9c24e600a2 100644
--- a/util/system/thread.i
+++ b/util/system/thread.i
@@ -1,52 +1,52 @@
-//do not use directly
+//do not use directly
#pragma once
-#include "platform.h"
+#include "platform.h"
-#if defined(_win_)
+#if defined(_win_)
#include "winint.h"
- #include <process.h>
-
- typedef HANDLE THREADHANDLE;
-#else
- #include <pthread.h>
- #include <sched.h>
- #include <errno.h>
- #include <string.h>
-
- typedef pthread_t THREADHANDLE;
-#endif
-
-#if defined(_freebsd_)
- #include <pthread_np.h>
-#elif defined(_linux_)
- #include <sys/prctl.h>
-#endif
-
-#include <util/digest/numeric.h>
+ #include <process.h>
+
+ typedef HANDLE THREADHANDLE;
+#else
+ #include <pthread.h>
+ #include <sched.h>
+ #include <errno.h>
+ #include <string.h>
+
+ typedef pthread_t THREADHANDLE;
+#endif
+
+#if defined(_freebsd_)
+ #include <pthread_np.h>
+#elif defined(_linux_)
+ #include <sys/prctl.h>
+#endif
+
+#include <util/digest/numeric.h>
static inline size_t SystemCurrentThreadIdImpl() noexcept {
- #if defined(_unix_)
- return (size_t)pthread_self();
- #elif defined(_win_)
- return (size_t)GetCurrentThreadId();
- #else
- #error todo
- #endif
-}
-
-template <class T>
+ #if defined(_unix_)
+ return (size_t)pthread_self();
+ #elif defined(_win_)
+ return (size_t)GetCurrentThreadId();
+ #else
+ #error todo
+ #endif
+}
+
+template <class T>
static inline T ThreadIdHashFunction(T t) noexcept {
- /*
- * we must permute threadid bits, because some strange platforms(such Linux)
- * have strange threadid numeric properties
+ /*
+ * we must permute threadid bits, because some strange platforms(such Linux)
+ * have strange threadid numeric properties
*
* Because they are alligned pointers to pthread_t rather that tid.
* Currently there is no way to get tid without syscall (slightly slower)
* (pthread_getthreadid_np is not implemeted in glibc/musl for some reason).
- */
- return IntHash(t);
-}
-
+ */
+ return IntHash(t);
+}
+
static inline size_t SystemCurrentThreadId() noexcept {
- return ThreadIdHashFunction(SystemCurrentThreadIdImpl());
-}
+ return ThreadIdHashFunction(SystemCurrentThreadIdImpl());
+}