STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
__gnu_debug::_Safe_unordered_container< _Container > Class Template Reference

Base class for constructing a safe unordered container type that tracks iterators that reference it. More...

#include <debug/safe_unordered_container.h>

Inheritance diagram for __gnu_debug::_Safe_unordered_container< _Container >:
__gnu_debug::_Safe_unordered_container_base __gnu_debug::_Safe_sequence_base

Public Member Functions

template<typename _Predicate >
void _M_invalidate_if (_Predicate __pred)
 
template<typename _Predicate >
void _M_invalidate_local_if (_Predicate __pred)
 
- Public Member Functions inherited from __gnu_debug::_Safe_unordered_container_base
void _M_attach_local (_Safe_iterator_base *__it, bool __constant)
 
void _M_attach_local_single (_Safe_iterator_base *__it, bool __constant) throw ()
 
void _M_detach_local (_Safe_iterator_base *__it)
 
void _M_detach_local_single (_Safe_iterator_base *__it) throw ()
 
- Public Member Functions inherited from __gnu_debug::_Safe_sequence_base
void _M_invalidate_all () const
 
void _M_attach (_Safe_iterator_base *__it, bool __constant)
 
void _M_attach_single (_Safe_iterator_base *__it, bool __constant) throw ()
 
void _M_detach (_Safe_iterator_base *__it)
 
void _M_detach_single (_Safe_iterator_base *__it) throw ()
 

Additional Inherited Members

- Public Attributes inherited from __gnu_debug::_Safe_unordered_container_base
_Safe_iterator_base_M_local_iterators
 The list of mutable local iterators that reference this container. More...
 
_Safe_iterator_base_M_const_local_iterators
 The list of constant local iterators that reference this container. More...
 
- Public Attributes inherited from __gnu_debug::_Safe_sequence_base
_Safe_iterator_base_M_iterators
 The list of mutable iterators that reference this container. More...
 
_Safe_iterator_base_M_const_iterators
 The list of constant iterators that reference this container. More...
 
unsigned int _M_version
 The container version number. This number may never be 0. More...
 
- Protected Member Functions inherited from __gnu_debug::_Safe_unordered_container_base
 _Safe_unordered_container_base ()
 
 _Safe_unordered_container_base (const _Safe_unordered_container_base &) noexcept
 
 _Safe_unordered_container_base (_Safe_unordered_container_base &&__x) noexcept
 
 ~_Safe_unordered_container_base ()
 
void _M_detach_all ()
 
void _M_swap (_Safe_unordered_container_base &__x)
 
- Protected Member Functions inherited from __gnu_debug::_Safe_sequence_base
 _Safe_sequence_base ()
 
 ~_Safe_sequence_base ()
 
void _M_detach_all ()
 
void _M_detach_singular ()
 
void _M_revalidate_singular ()
 
void _M_swap (_Safe_sequence_base &__x)
 
__gnu_cxx::__mutex & _M_get_mutex () throw ()
 

Detailed Description

template<typename _Container>
class __gnu_debug::_Safe_unordered_container< _Container >

Base class for constructing a safe unordered container type that tracks iterators that reference it.

The class template _Safe_unordered_container simplifies the construction of safe unordered containers that track the iterators that reference the container, so that the iterators are notified of changes in the container that may affect their operation, e.g., if the container invalidates its iterators or is destructed. This class template may only be used by deriving from it and passing the name of the derived class as its template parameter via the curiously recurring template pattern. The derived class must have iterator and const_iterator types that are instantiations of class template _Safe_iterator for this container and local_iterator and const_local_iterator types that are instantiations of class template _Safe_local_iterator for this container. Iterators will then be tracked automatically.

Member Function Documentation

template<typename _Container >
template<typename _Predicate >
void __gnu_debug::_Safe_unordered_container< _Container >::_M_invalidate_if ( _Predicate  __pred)

Invalidates all iterators x that reference this container, are not singular, and for which __pred(x) returns true. __pred will be invoked with the normal iterators nested in the safe ones.

39  {
40  typedef typename _Container::iterator iterator;
41  typedef typename _Container::const_iterator const_iterator;
42 
43  __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex());
44  for (_Safe_iterator_base* __iter = _M_iterators; __iter;)
45  {
46  iterator* __victim = static_cast<iterator*>(__iter);
47  __iter = __iter->_M_next;
48  if (!__victim->_M_singular() && __pred(__victim->base()))
49  {
50  __victim->_M_invalidate();
51  }
52  }
53 
54  for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;)
55  {
56  const_iterator* __victim = static_cast<const_iterator*>(__iter2);
57  __iter2 = __iter2->_M_next;
58  if (!__victim->_M_singular() && __pred(__victim->base()))
59  {
60  __victim->_M_invalidate();
61  }
62  }
63  }
_Safe_iterator_base * _M_const_iterators
The list of constant iterators that reference this container.
Definition: safe_base.h:184
_Safe_iterator_base * _M_iterators
The list of mutable iterators that reference this container.
Definition: safe_base.h:181
__gnu_cxx::__mutex & _M_get_mutex()
template<typename _Container >
template<typename _Predicate >
void __gnu_debug::_Safe_unordered_container< _Container >::_M_invalidate_local_if ( _Predicate  __pred)

Invalidates all local iterators x that reference this container, are not singular, and for which __pred(x) returns true. __pred will be invoked with the normal ilocal iterators nested in the safe ones.

71  {
72  typedef typename _Container::local_iterator local_iterator;
73  typedef typename _Container::const_local_iterator const_local_iterator;
74 
75  __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex());
76  for (_Safe_iterator_base* __iter = _M_local_iterators; __iter;)
77  {
78  local_iterator* __victim = static_cast<local_iterator*>(__iter);
79  __iter = __iter->_M_next;
80  if (!__victim->_M_singular() && __pred(__victim->base()))
81  {
82  __victim->_M_invalidate();
83  }
84  }
85 
86  for (_Safe_iterator_base* __iter2 = _M_const_local_iterators; __iter2;)
87  {
88  const_local_iterator* __victim =
89  static_cast<const_local_iterator*>(__iter2);
90  __iter2 = __iter2->_M_next;
91  if (!__victim->_M_singular() && __pred(__victim->base()))
92  {
93  __victim->_M_invalidate();
94  }
95  }
96  }
_Safe_iterator_base * _M_const_local_iterators
The list of constant local iterators that reference this container.
Definition: safe_unordered_base.h:131
_Safe_iterator_base * _M_local_iterators
The list of mutable local iterators that reference this container.
Definition: safe_unordered_base.h:128
__gnu_cxx::__mutex & _M_get_mutex()

The documentation for this class was generated from the following files: