/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/threading/queue/mpsc_intrusive_unordered.h
35 строк
868 B
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#pragma once /* Simple almost-wait-free unordered queue for low contention operations. It's wait-free for producers. Hanging producer can hide some items from consumer. */ #include <util/system/types.h> namespace NThreading { struct TIntrusiveNode { TIntrusiveNode* Next; }; class TMPSCIntrusiveUnordered { public: static constexpr ui32 NUMBER_OF_TRIES_FOR_CAS = 3; void Push(TIntrusiveNode* node) noexcept; TIntrusiveNode* PopMany() noexcept; TIntrusiveNode* Pop() noexcept; void Push(void* node) noexcept { Push(reinterpret_cast<TIntrusiveNode*>(node)); } private: TIntrusiveNode* HeadForCaS = nullptr; TIntrusiveNode* HeadForSwap = nullptr; TIntrusiveNode* NotReadyChain = nullptr; TIntrusiveNode* PopOneQueue = nullptr; }; }