From 1f38578de1adb15936d48b5efa489c474a8f848d Mon Sep 17 00:00:00 2001 From: khizmax Date: Sun, 13 Mar 2016 11:50:26 +0300 Subject: [PATCH] Docfix --- cds/intrusive/impl/skip_list.h | 44 ++++++++++++++++++++++++++++++++++ cds/intrusive/skip_list_nogc.h | 10 +++++++- cds/intrusive/skip_list_rcu.h | 13 +++++++++- cds/intrusive/split_list_rcu.h | 1 + 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/cds/intrusive/impl/skip_list.h b/cds/intrusive/impl/skip_list.h index 1e3e876b..fee5547b 100644 --- a/cds/intrusive/impl/skip_list.h +++ b/cds/intrusive/impl/skip_list.h @@ -990,7 +990,50 @@ namespace cds { namespace intrusive { } public: + ///@name Forward iterators (only for debugging purpose) + //@{ /// Iterator type + /** + The forward iterator has some features: + - it has no post-increment operator + - to protect the value, the iterator contains a GC-specific guard + another guard is required locally for increment operator. + For some GC (like as \p gc::HP), a guard is a limited resource per thread, so an exception (or assertion) "no free guard" + may be thrown if the limit of guard count per thread is exceeded. + - The iterator cannot be moved across thread boundary because it contains thread-private GC's guard. + - Iterator ensures thread-safety even if you delete the item the iterator points to. However, in case of concurrent + deleting operations there is no guarantee that you iterate all item in the list. + Moreover, a crash is possible when you try to iterate the next element that has been deleted by concurrent thread. + + @warning Use this iterator on the concurrent container for debugging purpose only. + + The iterator interface: + \code + class iterator { + public: + // Default constructor + iterator(); + + // Copy construtor + iterator( iterator const& src ); + + // Dereference operator + value_type * operator ->() const; + + // Dereference operator + value_type& operator *() const; + + // Preincrement operator + iterator& operator ++(); + + // Assignment operator + iterator& operator = (iterator const& src); + + // Equality operators + bool operator ==(iterator const& i ) const; + bool operator !=(iterator const& i ) const; + }; + \endcode + */ typedef skip_list::details::iterator< gc, node_traits, back_off, false > iterator; /// Const iterator type @@ -1029,6 +1072,7 @@ namespace cds { namespace intrusive { { return const_iterator(); } + //@} public: /// Inserts new node diff --git a/cds/intrusive/skip_list_nogc.h b/cds/intrusive/skip_list_nogc.h index dd5b0ab8..833be13e 100644 --- a/cds/intrusive/skip_list_nogc.h +++ b/cds/intrusive/skip_list_nogc.h @@ -608,7 +608,14 @@ namespace cds { namespace intrusive { } public: - /// Iterator type + ///@name Forward iterators + //@{ + /// Forward iterator + /** + The forward iterator for a split-list has some features: + - it has no post-increment operator + - it depends on iterator of underlying \p OrderedList + */ typedef skip_list::details::iterator< gc, node_traits, back_off, false > iterator; /// Const iterator type @@ -647,6 +654,7 @@ namespace cds { namespace intrusive { { return const_iterator(); } + //@} protected: //@cond diff --git a/cds/intrusive/skip_list_rcu.h b/cds/intrusive/skip_list_rcu.h index 0cd3e7ac..c97de56f 100644 --- a/cds/intrusive/skip_list_rcu.h +++ b/cds/intrusive/skip_list_rcu.h @@ -1335,7 +1335,17 @@ namespace cds { namespace intrusive { } public: - /// Iterator type + ///@name Forward iterators (thread-safe under RCU lock) + //@{ + /// Forward iterator + /** + The forward iterator has some features: + - it has no post-increment operator + - it depends on iterator of underlying \p OrderedList + + You may safely use iterators in multi-threaded environment only under RCU lock. + Otherwise, a crash is possible if another thread deletes the element the iterator points to. + */ typedef skip_list::details::iterator< gc, node_traits, back_off, false > iterator; /// Const iterator type @@ -1376,6 +1386,7 @@ namespace cds { namespace intrusive { { return const_iterator(); } + //@} public: /// Inserts new node diff --git a/cds/intrusive/split_list_rcu.h b/cds/intrusive/split_list_rcu.h index 0159b6e1..e17a0230 100644 --- a/cds/intrusive/split_list_rcu.h +++ b/cds/intrusive/split_list_rcu.h @@ -1037,6 +1037,7 @@ namespace cds { namespace intrusive { Otherwise, a crash is possible if another thread deletes the element the iterator points to. */ typedef iterator_type iterator; + /// Const forward iterator /** For iterator's features and requirements see \ref iterator -- 2.34.1