31 template <
typename ValueT>
32 void Push(ValueT &&value) {
33 std::lock_guard<std::mutex> lock(
_mutex);
34 auto new_list = std::make_shared<ListT>(*
Load());
35 new_list->emplace_back(std::forward<ValueT>(value));
40 std::lock_guard<std::mutex> lock(
_mutex);
41 auto new_list = std::make_shared<ListT>(*
Load());
42 auto begin = new_list->begin();
43 std::advance(begin, index);
44 new_list->erase(begin);
48 template <
typename ValueT>
50 std::lock_guard<std::mutex> lock(
_mutex);
51 auto new_list = std::make_shared<ListT>(*
Load());
52 new_list->erase(std::remove(new_list->begin(), new_list->end(), value), new_list->end());
57 std::lock_guard<std::mutex> lock(
_mutex);
58 _list = std::make_shared<ListT>();
62 std::shared_ptr<const ListT>
Load()
const {
A very simple atomic shared ptr with release-acquire memory order.
std::shared_ptr< T > load() const noexcept
Inherit (privately) to suppress copy/move construction and assignment.
Holds an atomic pointer to a list.
void DeleteByValue(const ValueT &value)
void Push(ValueT &&value)
void DeleteByIndex(size_t index)
std::shared_ptr< const ListT > Load() const
Returns a pointer to the list.
AtomicSharedPtr< const ListT > _list
This file contains definitions of common data structures used in traffic manager.