aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/futex_like.cpp
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commitc2a1af049e9deca890e9923abe64fe6c59060348 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/messagebus/futex_like.cpp
parent1f553f46fb4f3c5eec631352cdd900a0709016af (diff)
downloadydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/futex_like.cpp')
-rw-r--r--library/cpp/messagebus/futex_like.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/library/cpp/messagebus/futex_like.cpp b/library/cpp/messagebus/futex_like.cpp
index c0d5b4f4ec..7f965126db 100644
--- a/library/cpp/messagebus/futex_like.cpp
+++ b/library/cpp/messagebus/futex_like.cpp
@@ -1,55 +1,55 @@
-#include <util/system/platform.h>
-
-#ifdef _linux_
-#include <sys/syscall.h>
-#include <linux/futex.h>
+#include <util/system/platform.h>
+
+#ifdef _linux_
+#include <sys/syscall.h>
+#include <linux/futex.h>
#if !defined(SYS_futex)
#define SYS_futex __NR_futex
-#endif
#endif
-
-#include <errno.h>
-
-#include <util/system/yassert.h>
-
-#include "futex_like.h"
-
-#ifdef _linux_
-namespace {
+#endif
+
+#include <errno.h>
+
+#include <util/system/yassert.h>
+
+#include "futex_like.h"
+
+#ifdef _linux_
+namespace {
int futex(int* uaddr, int op, int val, const struct timespec* timeout,
int* uaddr2, int val3) {
- return syscall(SYS_futex, uaddr, op, val, timeout, uaddr2, val3);
- }
-}
-#endif
-
-void TFutexLike::Wake(size_t count) {
+ return syscall(SYS_futex, uaddr, op, val, timeout, uaddr2, val3);
+ }
+}
+#endif
+
+void TFutexLike::Wake(size_t count) {
Y_ASSERT(count > 0);
-#ifdef _linux_
- if (count > unsigned(Max<int>())) {
- count = Max<int>();
- }
+#ifdef _linux_
+ if (count > unsigned(Max<int>())) {
+ count = Max<int>();
+ }
int r = futex(&Value, FUTEX_WAKE, count, nullptr, nullptr, 0);
Y_VERIFY(r >= 0, "futex_wake failed: %s", strerror(errno));
-#else
- TGuard<TMutex> guard(Mutex);
- if (count == 1) {
- CondVar.Signal();
- } else {
- CondVar.BroadCast();
- }
-#endif
-}
-
-void TFutexLike::Wait(int expected) {
-#ifdef _linux_
+#else
+ TGuard<TMutex> guard(Mutex);
+ if (count == 1) {
+ CondVar.Signal();
+ } else {
+ CondVar.BroadCast();
+ }
+#endif
+}
+
+void TFutexLike::Wait(int expected) {
+#ifdef _linux_
int r = futex(&Value, FUTEX_WAIT, expected, nullptr, nullptr, 0);
Y_VERIFY(r >= 0 || errno == EWOULDBLOCK, "futex_wait failed: %s", strerror(errno));
-#else
- TGuard<TMutex> guard(Mutex);
- if (expected == Get()) {
- CondVar.WaitI(Mutex);
- }
-#endif
-}
+#else
+ TGuard<TMutex> guard(Mutex);
+ if (expected == Get()) {
+ CondVar.WaitI(Mutex);
+ }
+#endif
+}