18 mutable std::recursive_mutex _mutex{};
22 using Index =
typename std::list<T>::const_iterator;
28 std::vector<T>
get()
const
30 std::lock_guard lock{ _mutex };
31 return std::vector<T>{ _list.begin(), _list.end() };
41 std::lock_guard lock{ _mutex };
42 _list.push_back(item);
43 return std::prev(_list.cend());
52 std::lock_guard lock{ _mutex };
A simple thread safe list of items.
Definition: GuardedList.h:16
Index add(const T &item)
Adds the given item to the list and returns its index.
Definition: GuardedList.h:39
std::vector< T > get() const
Gets a copy of the list of items.
Definition: GuardedList.h:28
typename std::list< T >::const_iterator Index
Type of an item index.
Definition: GuardedList.h:22
void remove(const Index &index)
Removes the item at the given index from the list.
Definition: GuardedList.h:50