aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/queue/mpmc_unordered_ring.h
diff options
context:
space:
mode:
authoragri <agri@yandex-team.ru>2022-02-10 16:48:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:12 +0300
commitd3530b2692e400bd4d29bd4f07cafaee139164e7 (patch)
treeb7ae636a74490e649a2ed0fdd5361f1bec83b9f9 /library/cpp/threading/queue/mpmc_unordered_ring.h
parent0f4c5d1e8c0672bf0a1f2f2d8acac5ba24772435 (diff)
downloadydb-d3530b2692e400bd4d29bd4f07cafaee139164e7.tar.gz
Restoring authorship annotation for <agri@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading/queue/mpmc_unordered_ring.h')
-rw-r--r--library/cpp/threading/queue/mpmc_unordered_ring.h84
1 files changed, 42 insertions, 42 deletions
diff --git a/library/cpp/threading/queue/mpmc_unordered_ring.h b/library/cpp/threading/queue/mpmc_unordered_ring.h
index 5042f7528e..59758d2c35 100644
--- a/library/cpp/threading/queue/mpmc_unordered_ring.h
+++ b/library/cpp/threading/queue/mpmc_unordered_ring.h
@@ -1,42 +1,42 @@
-#pragma once
-
-/*
- It's not a general purpose queue.
- No order guarantee, but it mostly ordered.
- Items may stuck in almost empty queue.
- Use UnsafeScanningPop to pop all stuck items.
- Almost wait-free for producers and consumers.
- */
-
-#include <util/system/atomic.h>
-#include <util/generic/ptr.h>
-
-namespace NThreading {
- struct TMPMCUnorderedRing {
- public:
- static constexpr ui16 MAX_PUSH_TRIES = 4;
- static constexpr ui16 MAX_POP_TRIES = 4;
-
- TMPMCUnorderedRing(size_t size);
-
- bool Push(void* msg, ui16 retryCount = MAX_PUSH_TRIES) noexcept;
- void StubbornPush(void* msg) {
- while (!WeakPush(msg)) {
- }
- }
-
- void* Pop() noexcept;
-
- void* UnsafeScanningPop(ui64* last) noexcept;
-
- private:
- bool WeakPush(void* msg) noexcept;
-
- size_t RingSize;
- TArrayPtr<void*> RingBuffer;
- ui64 WritePawl = 0;
- ui64 WriteFront = 0;
- ui64 ReadPawl = 0;
- ui64 ReadFront = 0;
- };
-}
+#pragma once
+
+/*
+ It's not a general purpose queue.
+ No order guarantee, but it mostly ordered.
+ Items may stuck in almost empty queue.
+ Use UnsafeScanningPop to pop all stuck items.
+ Almost wait-free for producers and consumers.
+ */
+
+#include <util/system/atomic.h>
+#include <util/generic/ptr.h>
+
+namespace NThreading {
+ struct TMPMCUnorderedRing {
+ public:
+ static constexpr ui16 MAX_PUSH_TRIES = 4;
+ static constexpr ui16 MAX_POP_TRIES = 4;
+
+ TMPMCUnorderedRing(size_t size);
+
+ bool Push(void* msg, ui16 retryCount = MAX_PUSH_TRIES) noexcept;
+ void StubbornPush(void* msg) {
+ while (!WeakPush(msg)) {
+ }
+ }
+
+ void* Pop() noexcept;
+
+ void* UnsafeScanningPop(ui64* last) noexcept;
+
+ private:
+ bool WeakPush(void* msg) noexcept;
+
+ size_t RingSize;
+ TArrayPtr<void*> RingBuffer;
+ ui64 WritePawl = 0;
+ ui64 WriteFront = 0;
+ ui64 ReadPawl = 0;
+ ui64 ReadFront = 0;
+ };
+}