cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
lock_free_queue.hpp File Reference
#include <algorithm>
#include <atomic>
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <unordered_map>
#include <vector>
#include <cpp-toolbox/cpp-toolbox_export.hpp>
#include "cpp-toolbox/macro.hpp"
Include dependency graph for lock_free_queue.hpp:

Go to the source code of this file.

Classes

struct  toolbox::container::detail::HPRec
 危险指针记录结构体 (Hazard Pointer Record structure) More...
 
class  toolbox::container::detail::HazardPointerGuard
 危险指针设置/清除的RAII助手类 (RAII helper for setting/clearing hazard pointers) More...
 
class  toolbox::container::lock_free_queue_t< T >
 

Namespaces

namespace  toolbox
 
namespace  toolbox::container
 
namespace  toolbox::container::detail
 

Functions

HPRectoolbox::container::detail::acquire_hp_record ()
 
void toolbox::container::detail::release_hp_record (HPRec *rec)
 释放危险指针记录 (Release a hazard pointer record)
 
void toolbox::container::detail::set_hazard_pointer (size_t index, void *ptr)
 为当前线程设置一个危险指针 (Set a hazard pointer for the current thread)
 
void toolbox::container::detail::clear_hazard_pointer (size_t index)
 清除当前线程的一个危险指针 (Clear a hazard pointer for the current thread)
 
void toolbox::container::detail::scan_retired_nodes ()
 扫描已退休节点并删除安全的节点 (Scan retired nodes and delete safe ones)
 
void toolbox::container::detail::retire_node (void *node, std::function< void(void *)> deleter)
 退休一个节点(添加到线程本地列表,偶尔触发扫描) (Retire a node - add to thread-local list, trigger scan occasionally)
 
void toolbox::container::detail::cleanup_retired_nodes ()
 清理当前线程的所有剩余退休节点 (Clean up all remaining retired nodes for the current thread)
 

Variables

std::vector< HPRec * > toolbox::container::detail::g_hp_list
 
std::mutex toolbox::container::detail::g_hp_list_mutex
 
thread_local std::vector< std::pair< void *, std::function< void(void *)> > > toolbox::container::detail::t_retired_list
 
constexpr size_t toolbox::container::detail::MAX_HAZARD_POINTERS_PER_THREAD = 2
 
constexpr size_t toolbox::container::detail::RETIRE_SCAN_THRESHOLD = 100