From aa9408f1943c145e075cfe4a67e84d26f62be787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org> Date: Tue, 11 Apr 2023 16:28:36 +0200 Subject: [PATCH] [doc] Document thread safety guarantees of MatrixIndexSet --- dune/istl/matrixindexset.hh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dune/istl/matrixindexset.hh b/dune/istl/matrixindexset.hh index c6c60bd16..ae563d30d 100644 --- a/dune/istl/matrixindexset.hh +++ b/dune/istl/matrixindexset.hh @@ -28,6 +28,10 @@ namespace Dune { * The default value for maxVectorSize works well and ensures * that the slow std::set fallback is only used for very * dense rows. + * + * This class is thread safe in the sense that concurrent calls + * to all const methods and furthermore to add(row,col) with different + * rows in each thread are safe. */ class MatrixIndexSet { @@ -98,7 +102,13 @@ namespace Dune { indices_.resize(rows_, FlatSet()); } - /** \brief Add an index to the index set */ + /** + * \brief Add an index to the index set + * + * It is safe to call add(row, col) for different rows in concurrent threads, + * but it is not safe to do concurrent calls for the same row, even for different + * columns. + */ void add(size_type row, size_type col) { return std::visit(Dune::overload( // If row is stored as set, call insert directly -- GitLab