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
commit1f553f46fb4f3c5eec631352cdd900a0709016af (patch)
treea231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/messagebus/futex_like.cpp
parentc4de7efdedc25b49cbea74bd589eecb61b55b60a (diff)
downloadydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 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 7f965126db..c0d5b4f4ec 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
-#endif
-
-#include <errno.h>
-
-#include <util/system/yassert.h>
-
-#include "futex_like.h"
-
-#ifdef _linux_
-namespace {
+
+#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
+}