diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | c2a1af049e9deca890e9923abe64fe6c59060348 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/messagebus/lfqueue_batch.h | |
parent | 1f553f46fb4f3c5eec631352cdd900a0709016af (diff) | |
download | ydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/lfqueue_batch.h')
-rw-r--r-- | library/cpp/messagebus/lfqueue_batch.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/messagebus/lfqueue_batch.h b/library/cpp/messagebus/lfqueue_batch.h index f3db73a3dd..8128d3154d 100644 --- a/library/cpp/messagebus/lfqueue_batch.h +++ b/library/cpp/messagebus/lfqueue_batch.h @@ -1,36 +1,36 @@ -#pragma once - +#pragma once + #include <library/cpp/messagebus/actor/temp_tls_vector.h> -#include <util/generic/vector.h> -#include <util/thread/lfstack.h> - +#include <util/generic/vector.h> +#include <util/thread/lfstack.h> + template <typename T, template <typename, class> class TVectorType = TVector> -class TLockFreeQueueBatch { -private: +class TLockFreeQueueBatch { +private: TLockFreeStack<TVectorType<T, std::allocator<T>>*> Stack; -public: - bool IsEmpty() { - return Stack.IsEmpty(); - } - +public: + bool IsEmpty() { + return Stack.IsEmpty(); + } + void EnqueueAll(TAutoPtr<TVectorType<T, std::allocator<T>>> vec) { - Stack.Enqueue(vec.Release()); - } - + Stack.Enqueue(vec.Release()); + } + void DequeueAllSingleConsumer(TVectorType<T, std::allocator<T>>* r) { TTempTlsVector<TVectorType<T, std::allocator<T>>*> vs; - Stack.DequeueAllSingleConsumer(vs.GetVector()); - + Stack.DequeueAllSingleConsumer(vs.GetVector()); + for (typename TVector<TVectorType<T, std::allocator<T>>*>::reverse_iterator i = vs.GetVector()->rbegin(); i != vs.GetVector()->rend(); ++i) { - if (i == vs.GetVector()->rend()) { - r->swap(**i); - } else { - r->insert(r->end(), (*i)->begin(), (*i)->end()); - } - delete *i; - } - } -}; + if (i == vs.GetVector()->rend()) { + r->swap(**i); + } else { + r->insert(r->end(), (*i)->begin(), (*i)->end()); + } + delete *i; + } + } +}; |