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 | cde218e65dfef5ce03a48d641fd8f7913cf17b2d (patch) | |
tree | d3349caea4095825a55b5ba24fe758067b29ce6f /util/thread/lfqueue.h | |
parent | 9f813499b4ef585cb3c2bb93de93ef003daf4fc4 (diff) | |
download | ydb-cde218e65dfef5ce03a48d641fd8f7913cf17b2d.tar.gz |
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 1 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 ab523631e4..451bff0743 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; +}; |