diff options
author | stanly <stanly@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:49 +0300 |
commit | 6170310e8721e225f64ddabf7a7358253d7a1249 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /util/thread/lfqueue.h | |
parent | cde218e65dfef5ce03a48d641fd8f7913cf17b2d (diff) | |
download | ydb-6170310e8721e225f64ddabf7a7358253d7a1249.tar.gz |
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/thread/lfqueue.h')
-rw-r--r-- | util/thread/lfqueue.h | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/util/thread/lfqueue.h b/util/thread/lfqueue.h index 451bff0743..ab523631e4 100644 --- a/util/thread/lfqueue.h +++ b/util/thread/lfqueue.h @@ -2,7 +2,7 @@ #include "fwd.h" -#include <util/generic/ptr.h> +#include <util/generic/ptr.h> #include <util/system/atomic.h> #include <util/system/yassert.h> #include "lfstack.h" @@ -358,41 +358,41 @@ public: return res; } }; - + template <class T, class TCounter> -class TAutoLockFreeQueue { -public: +class TAutoLockFreeQueue { +public: using TRef = THolder<T>; - + inline ~TAutoLockFreeQueue() { - TRef tmp; - + TRef tmp; + while (Dequeue(&tmp)) { } - } - - inline bool Dequeue(TRef* t) { + } + + inline bool Dequeue(TRef* t) { T* res = nullptr; - - if (Queue.Dequeue(&res)) { - t->Reset(res); - - return true; - } - - return false; - } - - inline void Enqueue(TRef& t) { - Queue.Enqueue(t.Get()); + + if (Queue.Dequeue(&res)) { + t->Reset(res); + + return true; + } + + return false; + } + + inline void Enqueue(TRef& t) { + Queue.Enqueue(t.Get()); Y_UNUSED(t.Release()); - } - - inline void Enqueue(TRef&& t) { - Queue.Enqueue(t.Get()); + } + + inline void Enqueue(TRef&& t) { + Queue.Enqueue(t.Get()); Y_UNUSED(t.Release()); - } - + } + inline bool IsEmpty() { return Queue.IsEmpty(); } @@ -401,6 +401,6 @@ public: return Queue.GetCounter(); } -private: - TLockFreeQueue<T*, TCounter> Queue; -}; +private: + TLockFreeQueue<T*, TCounter> Queue; +}; |