aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/thread.i
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/thread.i
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 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 9c24e600a2..8cba505473 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());
+}